MCPcopy Create free account
hub / github.com/dolthub/doltgresql / geomToGeoJSONCRS

Function geomToGeoJSONCRS

postgres/parser/geo/encode.go:107–125  ·  view source on GitHub ↗

geomToGeoJSONCRS converts a geom to its CRS GeoJSON form.

(t geom.T, long bool)

Source from the content-addressed store, hash-verified

105
106// geomToGeoJSONCRS converts a geom to its CRS GeoJSON form.
107func 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.
128func SpatialObjectToGeoJSON(

Callers 1

SpatialObjectToGeoJSONFunction · 0.85

Calls 3

ProjectionFunction · 0.92
SRIDTypeAlias · 0.92
SRIDMethod · 0.45

Tested by

no test coverage detected