MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / parseGeoHash

Function parseGeoHash

pkg/geo/parse.go:232–251  ·  view source on GitHub ↗
(g string, precision int)

Source from the content-addressed store, hash-verified

230}
231
232func parseGeoHash(g string, precision int) (geohash.Box, error) {
233 if len(g) == 0 {
234 return geohash.Box{}, pgerror.Newf(pgcode.InvalidParameterValue, "length of GeoHash must be greater than 0")
235 }
236
237 // In PostGIS the parsing is case-insensitive.
238 g = strings.ToLower(g)
239
240 // If precision is more than the length of the geohash
241 // or if precision is less than 0 then set
242 // precision equal to length of geohash.
243 if precision > len(g) || precision < 0 {
244 precision = len(g)
245 }
246 box, err := geohash.Decode(g[:precision])
247 if err != nil {
248 return geohash.Box{}, pgerror.Wrap(err, pgcode.InvalidParameterValue, "invalid GeoHash")
249 }
250 return box, nil
251}
252
253// GeometryToEncodedPolyline turns the provided geometry and precision into a Polyline ASCII
254func GeometryToEncodedPolyline(g Geometry, p int) (string, error) {

Calls 3

NewfFunction · 0.92
WrapFunction · 0.92
DecodeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…