public void normalize() { for (int i = 0; i < geometries.length; i++) { geometries[i].normalize(); } Arrays.sort(geometries); }

/** * Creates a new Geometry which is a normalized * copy of this Geometry. * * @return a normalized copy of this geometry. * @see #normalize() */ public Geometry norm() { Geometry copy = (Geometry) clone(); copy.normalize(); return copy; }

/** * Converts this Geometry to normal form (canonical form). * * @param geometry * @return */ public static Geometry normalize(Geometry geometry) { if(geometry == null){ return null; } geometry.normalize(); return geometry; } }

/** * Converts this Geometry to normal form (canonical form). * * @param geometry * @return */ public static Geometry normalize(Geometry geometry) { if(geometry == null){ return null; } geometry.normalize(); return geometry; } }

public void normalize() { for (int i = 0; i < geometries.length; i++) { geometries[i].normalize(); } Arrays.sort(geometries); }

Geometry normalizeIfNeeded(Geometry value) { if (value instanceof Polygon) { value.normalize(); } else if (value instanceof MultiPolygon || GeometryCollection.class.equals(value.getClass())) {// ignore // multipoint/linestring normalize((GeometryCollection) value); } return value; }

/** * Creates a new Geometry which is a normalized * copy of this Geometry. * * @return a normalized copy of this geometry. * @see #normalize() */ public Geometry norm() { Geometry copy = (Geometry) clone(); copy.normalize(); return copy; }

if(geom instanceof Polygon){ if(geom.isValid()){ geom.normalize(); // validate does not pick up rings in the wrong order - this will fix that return geom; // If the polygon is valid just return it }else if(geom instanceof MultiPolygon){ if(geom.isValid()){ geom.normalize(); // validate does not pick up rings in the wrong order - this will fix that return geom; // If the multipolygon is valid just return it

## Javadoc

Converts this

`Geometry`

to **normal form**(or**canonical form**). Normal form is a unique representation for`Geometry`

s. It can be used to test whether two `Geometry`

s are equal
in a way that is independent of the ordering of the coordinates within
them. Normal form equality is a stronger condition than topological
equality, but weaker than pointwise equality. The definitions for normal
form use the standard lexicographical ordering for coordinates. "Sorted in
order of coordinates" means the obvious extension of this ordering to
sequences of coordinates.
NOTE that this method mutates the value of this geometry in-place. If this is not safe and/or wanted, the geometry should be cloned prior to normalization.

## Popular methods of Geometry

- getEnvelopeInternalGets an Envelope containing the minimum and maximum x and y values in this Geometry. If the geometr
- getCoordinatesReturns an array containing the values of all the vertices for this geometry. If the geometry is a c
- isEmptyTests whether the set of points covered by this Geometry is empty.
- getCentroidComputes the centroid of this Geometry. The centroid is equal to the centroid of the set of componen
- getGeometryNReturns an element Geometry from a GeometryCollection(or this, if the geometry is not a collection).
- toTextReturns the Well-known Text representation of this Geometry. For a definition of the Well-known Text
- getNumGeometriesReturns the number of Geometrys in a GeometryCollection(or 1, if the geometry is not a collection).
- getFactoryGets the factory which contains the context in which this geometry was created.
- getGeometryTypeReturns the name of this Geometry's actual class.
- getSRIDReturns the ID of the Spatial Reference System used by the Geometry. JTS supports Spatial Reference
- getCoordinateReturns a vertex of this Geometry (usually, but not necessarily, the first one). The returned coordi
- intersectionComputes a Geometry representing the point-set which is common to both this Geometry and the other

## Popular in Java

- Reading from database using SQL prepared statement
- onRequestPermissionsResult (Fragment)
- getApplicationContext (Context)
- addToBackStack (FragmentTransaction)
- Rectangle (java.awt)A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
- MessageDigest (java.security)Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
- Hashtable (java.util)A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
- Scanner (java.util)A parser that parses a text string of primitive types and strings with the help of regular expressio
- JarFile (java.util.jar)JarFile is used to read jar entries and their associated data from jar files.
- JTable (javax.swing)
- Top 25 Plugins for Webstorm