parse diffs till </osmChange>
- changes and err chan are now closed on success - io.EOF is now an error - fixes (possible) parsing of truncated diff files closes #45
parent
2aa45895e1
commit
0be4fcf565
|
@ -3,10 +3,11 @@ package parser
|
|||
import (
|
||||
"compress/gzip"
|
||||
"encoding/xml"
|
||||
"github.com/omniscale/imposm3/element"
|
||||
"github.com/omniscale/imposm3/logging"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/omniscale/imposm3/element"
|
||||
"github.com/omniscale/imposm3/logging"
|
||||
)
|
||||
|
||||
var log = logging.NewLogger("osc parser")
|
||||
|
@ -171,6 +172,8 @@ NextToken:
|
|||
e.Rel = rel
|
||||
rel = &element.Relation{}
|
||||
newElem = true
|
||||
case "osmChange":
|
||||
return
|
||||
}
|
||||
|
||||
if newElem {
|
||||
|
|
|
@ -3,7 +3,6 @@ package diff
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
|
@ -137,10 +136,14 @@ func Update(oscFile string, geometryLimiter *limit.Limiter, expireor expire.Expi
|
|||
step := log.StartStep("Parsing changes, updating cache and removing elements")
|
||||
|
||||
g := geos.NewGeos()
|
||||
For:
|
||||
|
||||
for {
|
||||
select {
|
||||
case elem := <-elems:
|
||||
case elem, ok := <-elems:
|
||||
if !ok {
|
||||
elems = nil
|
||||
break
|
||||
}
|
||||
if elem.Rel != nil {
|
||||
relTagFilter.Filter(&elem.Rel.Tags)
|
||||
progress.AddRelations(1)
|
||||
|
@ -237,11 +240,15 @@ For:
|
|||
}
|
||||
}
|
||||
}
|
||||
case err := <-errc:
|
||||
if err != io.EOF {
|
||||
return diffError(err, "")
|
||||
case err, ok := <-errc:
|
||||
if !ok {
|
||||
errc = nil
|
||||
break
|
||||
}
|
||||
break For
|
||||
return diffError(err, "")
|
||||
}
|
||||
if errc == nil && elems == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue