diff --git a/config/config.go b/config/config.go index 0b589a1..7ef26e4 100644 --- a/config/config.go +++ b/config/config.go @@ -143,7 +143,7 @@ func (o *_BaseOptions) updateFromConfig() error { } } - if conf.DiffStateBefore.Duration != 0 && o.DiffStateBefore == 2*time.Hour { + if conf.DiffStateBefore.Duration != 0 && o.DiffStateBefore == 0 { o.DiffStateBefore = conf.DiffStateBefore.Duration } return nil @@ -226,7 +226,7 @@ func init() { ImportFlags.BoolVar(&ImportOptions.DeployProduction, "deployproduction", false, "deploy production") ImportFlags.BoolVar(&ImportOptions.RevertDeploy, "revertdeploy", false, "revert deploy to production") ImportFlags.BoolVar(&ImportOptions.RemoveBackup, "removebackup", false, "remove backups from deploy") - ImportFlags.DurationVar(&BaseOptions.DiffStateBefore, "diff-state-before", 2*time.Hour, "set initial diff sequence before") + ImportFlags.DurationVar(&BaseOptions.DiffStateBefore, "diff-state-before", 0, "set initial diff sequence before") DiffFlags.StringVar(&BaseOptions.ExpireTilesDir, "expiretiles-dir", "", "write expire tiles into dir") DiffFlags.IntVar(&BaseOptions.ExpireTilesZoom, "expiretiles-zoom", 14, "write expire tiles in this zoom level") diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 81531de..b6d60d4 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -210,7 +210,9 @@ To start the update process:: You can stop processing new diff files SIGTERM (``crtl-c``), SIGKILL or SIGHUP. You should create systemd/upstart/init.d service for ``imposm3 run`` to always run in background. -You can change to hourly updates by adding `replication_url: "https://planet.openstreetmap.org/replication/hour/"` and `replication_interval: "1h"` to the Imposm configuration. +You can change to hourly updates by adding `replication_url: "https://planet.openstreetmap.org/replication/hour/"` and `replication_interval: "1h"` to the Imposm configuration. Same for daily updates (works also for Geofabrik updates): `replication_url: "https://planet.openstreetmap.org/replication/day/"` and `replication_interval: "24h"`. + +At import time, Imposm compute the first diff sequence number by comparing the PBF input file timestamp and the latest state available in the remote server. Depending on the PBF generation process, this sequence number may not be correct, you can force Imposm to start with an earlier sequence number by adding a `diff_state_before` duration in your conf file. For example, `diff_state_before: 4h` will start with an initial sequence number generated 4 hours before the PBF generation time. One-time update diff --git a/replication/source.go b/replication/source.go index 3bd9042..1d39caa 100644 --- a/replication/source.go +++ b/replication/source.go @@ -174,7 +174,7 @@ func (d *downloader) fetchNextLoop() { lastTime, err := d.stateTime(stateFile) for { nextSeq := d.lastSequence + 1 - log.Print("Processing sequence ", nextSeq, err) + log.Print("Processing sequence ", nextSeq) if err == nil { nextDiffTime := lastTime.Add(d.interval) if nextDiffTime.After(time.Now()) { diff --git a/update/state/state.go b/update/state/state.go index f5bfcbc..548709c 100644 --- a/update/state/state.go +++ b/update/state/state.go @@ -105,7 +105,7 @@ func FromPbf(filename string, before time.Duration) (*DiffState, error) { } // start earlier - seq -= int(before.Minutes()) + seq -= int(before.Minutes() / config.BaseOptions.ReplicationInterval.Minutes()) return &DiffState{Time: timestamp, Url: replicationUrl, Sequence: seq}, nil }