geomToGeoJSONCRS converts a geom to its CRS GeoJSON form.
(t geom.T, long bool)
| 105 | |
| 106 | // geomToGeoJSONCRS converts a geom to its CRS GeoJSON form. |
| 107 | func geomToGeoJSONCRS(t geom.T, long bool) (*geojson.CRS, error) { |
| 108 | projection, ok := geoprojbase.Projection(geopb.SRID(t.SRID())) |
| 109 | if !ok { |
| 110 | return nil, errors.Newf("unknown SRID: %d", t.SRID()) |
| 111 | } |
| 112 | var prop string |
| 113 | if long { |
| 114 | prop = fmt.Sprintf("urn:ogc:def:crs:%s::%d", projection.AuthName, projection.AuthSRID) |
| 115 | } else { |
| 116 | prop = fmt.Sprintf("%s:%d", projection.AuthName, projection.AuthSRID) |
| 117 | } |
| 118 | crs := &geojson.CRS{ |
| 119 | Type: "name", |
| 120 | Properties: map[string]interface{}{ |
| 121 | "name": prop, |
| 122 | }, |
| 123 | } |
| 124 | return crs, nil |
| 125 | } |
| 126 | |
| 127 | // SpatialObjectToGeoJSON transforms a given SpatialObject to GeoJSON. |
| 128 | func SpatialObjectToGeoJSON( |
no test coverage detected