Add Normalize

Open
#387 0 comments 0 reactions 1 assignee View on GitHub

@peterstace is already working on this.

Since Feb 3, 2023.

Assessment

This issue has not been assessed yet.

Description

algorithm breaking change feature

See https://postgis.net/docs/ST_Normalize.html

  • Add a new method Normalize() T to each geometry type.
  • It should return a new version of the geometry that has been put into a normalized form.
  • The normalized forms of two geometry that are ExactEqual using the IgnoreOrder should be ExactEqual without using the IgnoreOrder.
  • Normalize should only affect the ordering within a geometry.
  • We shouldn't document the ordering rules, in case we need to change them.

The rules could be something like this:

  • An ordering can be put on coordinates. Leftmost-then-lowest for XY, then Z and M (in that order) used as tie breakers.
  • Points are unaltered.
  • MultiPoints are ordered internally by the coordinates of their points.
  • LineStrings are reverse depending on their endpoints ordering. If the endpoints are the same consider the points next to the endpoints etc.
  • MultiLineStrings: re-order linestrings first. The put children in order of their first points. Use second (etc) points as tie breakers.
  • Polygons: each ring needs to get a new start endpoint. It should be smallest point on the ring (by coordinate ordering). If there happen to be duplicate points on the ring that are smallest, then duplicates should come immediately next in the ring order. Polygons should then we wound consistently (e.g. outer rings are CCW as per http://opengeospatial.org/standards/sfa). Inner rings should be sorted as well in some way.
  • MultiPolygons: sort out child internally first. Then sort the children between each other.
  • GeometryCollection: GeometryCollection, MultiPoly, Poly, MultiLS, LS, MultiPt, Pt. Then among each category, sort as well.

We should also remove the ExactEqual option to ignore order. Users can use Normalize instead. So this would be a breaking change.

Dominant language
Go
Stars
176
Forks
27
Avg merge
1d 20h
Merged PRs (30d)
6

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from peterstace/simplefeatures

All issues in peterstace/simplefeatures

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.