func (writer *OsmElemWriter) NodeToSrid(node *element.Node) { if writer.srid == 4326 { return } if writer.srid != 3857 && writer.srid != 900913 { panic("invalid srid. only 4326, 3857 and 900913 are supported") } node.Long, node.Lat = proj.WgsToMerc(node.Long, node.Lat) }
func transformPolygon(p geojson.Polygon, targetSRID int) { if targetSRID != 900913 && targetSRID != 3857 { panic("transformation to non-4326/3856 not implemented") } for _, ls := range p { for i := range ls { ls[i].Long, ls[i].Lat = proj.WgsToMerc(ls[i].Long, ls[i].Lat) } } }
func (writer *OsmElemWriter) NodesToSrid(nodes []element.Node) { if writer.srid == 4326 { return } if writer.srid != 3857 && writer.srid != 900913 { panic("invalid srid. only 4326, 3857 and 900913 are supported") } for i, nd := range nodes { nodes[i].Long, nodes[i].Lat = proj.WgsToMerc(nd.Long, nd.Lat) } }
func newPointFromCoords(coords []interface{}) (point, error) { p := point{} if len(coords) != 2 && len(coords) != 3 { return p, errors.New("point list length not 2 or 3") } var ok bool p.long, ok = coords[0].(float64) if !ok { return p, errors.New("invalid lon") } p.lat, ok = coords[1].(float64) if !ok { return p, errors.New("invalid lat") } if p.long >= -180.0 && p.long <= 180.0 && p.lat >= -90.0 && p.lat <= 90.0 { p.long, p.lat = proj.WgsToMerc(p.long, p.lat) } return p, nil }