2013-11-08 19:03:58 +04:00
|
|
|
package expire
|
|
|
|
|
|
|
|
import (
|
2014-08-04 17:19:35 +04:00
|
|
|
"github.com/omniscale/imposm3/element"
|
2016-11-22 19:06:58 +03:00
|
|
|
"github.com/omniscale/imposm3/proj"
|
2013-11-08 19:03:58 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
type Expireor interface {
|
|
|
|
Expire(long, lat float64)
|
2016-11-23 16:43:04 +03:00
|
|
|
ExpireNodes(nodes []element.Node, closed bool)
|
2013-11-08 19:03:58 +04:00
|
|
|
}
|
|
|
|
|
2016-11-23 16:43:04 +03:00
|
|
|
func ExpireProjectedNodes(expireor Expireor, nodes []element.Node, srid int, closed bool) {
|
2016-11-22 19:06:58 +03:00
|
|
|
if srid == 4326 {
|
2016-11-23 16:43:04 +03:00
|
|
|
expireor.ExpireNodes(nodes, closed)
|
|
|
|
} else if srid == 3857 {
|
|
|
|
nds := make([]element.Node, len(nodes))
|
|
|
|
for i, nd := range nodes {
|
|
|
|
nds[i].Long, nds[i].Lat = proj.MercToWgs(nd.Long, nd.Lat)
|
2016-11-22 19:06:58 +03:00
|
|
|
}
|
2016-11-23 16:43:04 +03:00
|
|
|
expireor.ExpireNodes(nds, closed)
|
2016-11-22 19:06:58 +03:00
|
|
|
} else {
|
|
|
|
panic("unsupported srid")
|
2013-11-08 19:03:58 +04:00
|
|
|
}
|
|
|
|
}
|
2017-02-01 13:19:37 +03:00
|
|
|
|
|
|
|
func ExpireProjectedNode(expireor Expireor, node element.Node, srid int) {
|
|
|
|
if srid == 4326 {
|
|
|
|
expireor.Expire(node.Long, node.Lat)
|
|
|
|
} else if srid == 3857 {
|
|
|
|
long, lat := proj.MercToWgs(node.Long, node.Lat)
|
|
|
|
expireor.Expire(long, lat)
|
|
|
|
} else {
|
|
|
|
panic("unsupported srid")
|
|
|
|
}
|
|
|
|
}
|