(g string, precision int)
| 230 | } |
| 231 | |
| 232 | func 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 |
| 254 | func GeometryToEncodedPolyline(g Geometry, p int) (string, error) { |
no test coverage detected
searching dependent graphs…