add support for 4326
parent
2afc987d2b
commit
e9363ddf4e
|
@ -84,7 +84,7 @@ func (o *_BaseOptions) updateFromConfig() error {
|
|||
if conf.Srid == 0 {
|
||||
conf.Srid = defaultSrid
|
||||
}
|
||||
if o.Srid != defaultSrid {
|
||||
if o.Srid == defaultSrid {
|
||||
o.Srid = conf.Srid
|
||||
}
|
||||
if o.MappingFile == "" {
|
||||
|
@ -116,8 +116,8 @@ func (o *_BaseOptions) updateFromConfig() error {
|
|||
|
||||
func (o *_BaseOptions) check() []error {
|
||||
errs := []error{}
|
||||
if o.Srid != 3857 {
|
||||
errs = append(errs, errors.New("srid!=3857 not implemented"))
|
||||
if o.Srid != 3857 && o.Srid != 4326 {
|
||||
errs = append(errs, errors.New("only -srid=3857 or -srid=4326 are supported"))
|
||||
}
|
||||
if o.MappingFile == "" {
|
||||
errs = append(errs, errors.New("missing mapping"))
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"imposm3/geom"
|
||||
"imposm3/geom/geos"
|
||||
"imposm3/mapping"
|
||||
"imposm3/proj"
|
||||
"imposm3/stats"
|
||||
"sync"
|
||||
)
|
||||
|
@ -49,7 +48,7 @@ func (nw *NodeWriter) loop() {
|
|||
for n := range nw.nodes {
|
||||
nw.progress.AddNodes(1)
|
||||
if matches := nw.pointMatcher.MatchNode(n); len(matches) > 0 {
|
||||
proj.NodeToMerc(n)
|
||||
nw.NodeToSrid(n)
|
||||
if nw.expireor != nil {
|
||||
nw.expireor.Expire(n.Long, n.Lat)
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"imposm3/geom"
|
||||
"imposm3/geom/geos"
|
||||
"imposm3/mapping"
|
||||
"imposm3/proj"
|
||||
"imposm3/stats"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -71,7 +70,7 @@ NextRel:
|
|||
}
|
||||
continue NextRel
|
||||
}
|
||||
proj.NodesToMerc(m.Way.Nodes)
|
||||
rw.NodesToSrid(m.Way.Nodes)
|
||||
}
|
||||
|
||||
// BuildRelation updates r.Members but we need all of them
|
||||
|
|
|
@ -8,7 +8,6 @@ import (
|
|||
"imposm3/geom"
|
||||
"imposm3/geom/geos"
|
||||
"imposm3/mapping"
|
||||
"imposm3/proj"
|
||||
"imposm3/stats"
|
||||
"sync"
|
||||
)
|
||||
|
@ -66,7 +65,7 @@ func (ww *WayWriter) loop() {
|
|||
if err != nil {
|
||||
continue
|
||||
}
|
||||
proj.NodesToMerc(w.Nodes)
|
||||
ww.NodesToSrid(w.Nodes)
|
||||
|
||||
inserted := false
|
||||
if matches := ww.lineMatcher.MatchWay(w); len(matches) > 0 {
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package writer
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"imposm3/cache"
|
||||
"imposm3/database"
|
||||
"imposm3/element"
|
||||
"imposm3/expire"
|
||||
"imposm3/geom/limit"
|
||||
"imposm3/logging"
|
||||
"imposm3/proj"
|
||||
"imposm3/stats"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var log = logging.NewLogger("writer")
|
||||
|
@ -60,3 +63,26 @@ func (writer *OsmElemWriter) SetExpireor(exp expire.Expireor) {
|
|||
func (writer *OsmElemWriter) Wait() {
|
||||
writer.wg.Wait()
|
||||
}
|
||||
|
||||
func (writer *OsmElemWriter) NodesToSrid(nodes []element.Node) {
|
||||
if writer.srid == 4326 {
|
||||
return
|
||||
}
|
||||
if writer.srid != 3857 {
|
||||
panic("invalid srid. only 4326 and 3857 are supported")
|
||||
}
|
||||
|
||||
for i, nd := range nodes {
|
||||
nodes[i].Long, nodes[i].Lat = proj.WgsToMerc(nd.Long, nd.Lat)
|
||||
}
|
||||
}
|
||||
|
||||
func (writer *OsmElemWriter) NodeToSrid(node *element.Node) {
|
||||
if writer.srid == 4326 {
|
||||
return
|
||||
}
|
||||
if writer.srid != 3857 {
|
||||
panic("invalid srid. only 4326 and 3857 are supported")
|
||||
}
|
||||
node.Long, node.Lat = proj.WgsToMerc(node.Long, node.Lat)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue