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
- notifyDataSetChanged (ArrayAdapter)
- requestLocationUpdates (LocationManager)
- addToBackStack (FragmentTransaction)
- GridLayout (java.awt)The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
- BufferedImage (java.awt.image)The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
- Kernel (java.awt.image)
- Comparator (java.util)A Comparator is used to compare two objects to determine their ordering with respect to each other.
- ReentrantLock (java.util.concurrent.locks)A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
- LogFactory (org.apache.commons.logging)Factory for creating Log instances, with discovery and configuration features similar to that employ
- Top PhpStorm plugins