changes

package module
v0.0.0-...-4ee44f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

README

Imposm-Changes

Imposm-Changes imports OpenStreetMap changeset information and metadata into a PostgreSQL/PostGIS database.

The resulting database can be used to build change monitoring and QA applications. OSM Observer is such an application.

Uses an limitations

Imposm-Changes imports planet dumps and extracts (.osm.pbf), diff files (.osc.gz) and changeset files (.osm.gz).

It should work for whole planet imports but is not optimized for. You will typically use the changes_bbox option to monitor a smaller region/country extent. This allows you to monitor the changes of the last few weeks with moderate server requirements.

Installation

go get -u github.com/omniscale/imposm-changes
go install github.com/omniscale/imposm-changes/cmd/imposm-changes

Run

mkdir imposm-changes
cd imposm-changes
cp $GOPATH/src/github.com/omniscale/imposm-changes/config.json ./

# Edit config.json with database connection and changes_bbox.

# Call `import` to make initial import.
imposm-changes -config config.json import path/to/initial.osm.pbf

# Call `run` to continuously download and import diff and changes files. 
# Start this via systemctl or similar in production.
# Make sure initial_history in config.json is large enough to cover all
# changes since the creation of your initial osm.pbf file.
imposm-changes -config config.json run

Example queries

Here are a few example queries, that demonstrate what you can do with the resulting database.

Count changes in the last 8 hours within a bounding box:

SELECT count(*) FROM changesets
WHERE bbox IS NOT NULL AND bbox && ST_MakeEnvelope(6.8, 50.8, 7.2, 52.6)
AND closed_at > (NOW() - INTERVAL '8 hours');

Count how many nodes where added, modified or deleted:

SELECT sum(case when add then 1 else 0 end) AS add,
       sum(case when modify then 1 else 0 end) AS modify,
       sum(case when delete then 1 else 0 end) AS delete
FROM nodes
WHERE changeset IN (
    SELECT id
    FROM changesets
    WHERE closed_at > (NOW() - INTERVAL '8 hours')
);

Query information about nodes that where added or modified by Open Wheelmap.Org:

SELECT id, add, modify, version, ST_AsText(geometry), tags, timestamp
FROM nodes
WHERE (add OR modify)
AND changeset IN (
    SELECT id
    FROM changesets
    WHERE tags->'comment' = 'Modified via wheelmap.org'
);

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	InitialHistory:    config.MinutesInterval{Duration: 2 * time.Hour},
	DiffUrl:           "https://planet.openstreetmap.org/replication/minute/",
	DiffInterval:      config.MinutesInterval{Duration: time.Minute},
	ChangesetUrl:      "https://planet.openstreetmap.org/replication/changesets/",
	ChangesetInterval: config.MinutesInterval{Duration: time.Minute},
	Schemas:           Schemas{Changes: "changes"},
}
View Source
var Version string

Functions

func ImportChangeset

func ImportChangeset(db *database.PostGIS, limitTo *LimitTo, seq replication.Sequence) (err error)

func ImportDiff

func ImportDiff(db *database.PostGIS, limitTo *LimitTo, seq replication.Sequence) error

func ImportPBF

func ImportPBF(config *Config, pbfFilename string) error

func Run

func Run(config *Config) error

Types

type Config

type Config struct {
	Connection string   `json:"connection"`
	Schemas    Schemas  `json:"schemas"`
	LimitTo    *LimitTo `json:"changes_bbox"`
	DiffDir    string   `json:"diffdir"`
	ChangesDir string   `json:"changesdir"`

	DiffFromDiffDir         bool                   `json:"replication_from_diffdir"`
	DiffUrl                 string                 `json:"replication_url"`
	DiffInterval            config.MinutesInterval `json:"replication_interval"`
	ChangesetUrl            string                 `json:"changeset_url"`
	ChangesetInterval       config.MinutesInterval `json:"changeset_interval"`
	ChangesetFromChangesDir bool                   `json:"changeset_from_changesdir"`
	InitialHistory          config.MinutesInterval `json:"initial_history"`
}

func LoadConfig

func LoadConfig(filename string) (*Config, error)

type LimitTo

type LimitTo [4]float64

func (*LimitTo) Contains

func (l *LimitTo) Contains(long, lat float64) bool

Contains checks whether the given point is inside the LimitTo. Returns true if LimitTo is nil.

func (*LimitTo) Intersects

func (l *LimitTo) Intersects(o [4]float64) bool

Intersects checks whether the bbox intersects with the LimitTo. Returns true if LimitTo is nil or if o is zero.

type Schemas

type Schemas struct {
	Changes string `json:"changes"`
}

Directories

Path Synopsis
cmd
Package log provides a simple framework for reporting messages and the import progress.
Package log provides a simple framework for reporting messages and the import progress.
Package test provides system tests for Imposm3.
Package test provides system tests for Imposm3.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL