Converts this Geometry to normal form (canonical form).

@param geometry
@return
194055
public static Geometry normalize(Geometry geometry) {
        if(geometry == null){
            return null;
        }
        geometry.normalize();
        return geometry;
    }
288758
private Geometry cloneRecursively(Geometry geometry) {
		Geometry clone = new Geometry(geometry.geometryType, geometry.srid, geometry.precision);
		if (geometry.getGeometries() != null) {
			Geometry[] geometryClones = new Geometry[geometry.getGeometries().length];
			for (int i = 0; i < geometry.getGeometries().length; i++) {
				geometryClones[i] = cloneRecursively(geometry.getGeometries()[i]);
			}
			clone.setGeometries(geometryClones);
		}
		if (geometry.getCoordinates() != null) {
			Coordinate[] coordinateClones = new Coordinate[geometry.getCoordinates().length];
			for (int i = 0; i < geometry.getCoordinates().length; i++) {
				coordinateClones[i] = (Coordinate) geometry.getCoordinates()[i].clone();
			}
			clone.setCoordinates(coordinateClones);
		}
		return clone;
	}
9958
public JTSGeometryExpression<Geometry> difference(Expression<? extends Geometry> geometry) {
        return JTSGeometryExpressions.geometryOperation(SpatialOps.DIFFERENCE, mixin, geometry);
    }
325655
public static Triangle createTriangle(Geometry geom) throws IllegalArgumentException {
                Coordinate[] coordinates = geom.getCoordinates();
                if (coordinates.length != 4) {
                        throw new IllegalArgumentException("The geometry must be a triangle");
                }
                return new Triangle(coordinates[0],coordinates[1],coordinates[2]);
        }
32994
public static org.geomajas.gwt.client.spatial.geometry.Geometry toGwt(Geometry geometry) {
		if (geometry == null) {
			return null;
		}
		GeometryFactory factory = new GeometryFactory(geometry.getSrid(), geometry.getPrecision());
		org.geomajas.gwt.client.spatial.geometry.Geometry gwt;

		String geometryType = geometry.getGeometryType();
		if (Geometry.POINT.equals(geometryType)) {
			if (geometry.getCoordinates() != null) {
				gwt = factory.createPoint(geometry.getCoordinates()[0]);
			} else {
				gwt = factory.createPoint(null);
			}
		} else if (Geometry.LINEAR_RING.equals(geometryType)) {
			gwt = factory.createLinearRing(geometry.getCoordinates());
		} else if (Geometry.LINE_STRING.equals(geometryType)) {
			gwt = factory.createLineString(geometry.getCoordinates());
		} else if (Geometry.POLYGON.equals(geometryType)) {
			if (geometry.getGeometries() == null) {
				gwt = factory.createPolygon(null, null);
			} else {
				LinearRing exteriorRing = (LinearRing) toGwt(geometry.getGeometries()[0]);
				LinearRing[] interiorRings = new LinearRing[geometry.getGeometries().length - 1];
				for (int i = 0; i < interiorRings.length; i++) {
					interiorRings[i] = (LinearRing) toGwt(geometry.getGeometries()[i + 1]);
				}
				gwt = factory.createPolygon(exteriorRing, interiorRings);
			}
		} else if (Geometry.MULTI_POINT.equals(geometryType)) {
			if (geometry.getGeometries() == null) {
				gwt = factory.createMultiPoint(null);
			} else {
				Point[] points = new Point[geometry.getGeometries().length];
				gwt = factory.createMultiPoint((Point[]) convertGeometries(geometry, points));
			}
		} else if (Geometry.MULTI_LINE_STRING.equals(geometryType)) {
			if (geometry.getGeometries() == null) {
				gwt = factory.createMultiLineString(null);
			} else {
				LineString[] lineStrings = new LineString[geometry.getGeometries().length];
				gwt = factory.createMultiLineString((LineString[]) convertGeometries(geometry, lineStrings));
			}
		} else if (Geometry.MULTI_POLYGON.equals(geometryType)) {
			if (geometry.getGeometries() == null) {
				gwt = factory.createMultiPolygon(null);
			} else {
				Polygon[] polygons = new Polygon[geometry.getGeometries().length];
				gwt = factory.createMultiPolygon((Polygon[]) convertGeometries(geometry, polygons));
			}
		} else {
			String msg = "GeometryConverter.toGwt() unrecognized geometry type " + geometryType;
			Log.logServer(Log.LEVEL_ERROR, msg);
			throw new IllegalStateException(msg);
		}

		return gwt;
	}
455088
function(geometry) {
            var gml = this.createElementNS(this.gmlns, "gml:Polygon");
            var rings = geometry.components;
            var ringMember, ringGeom, type;
            for(var i=0; i<rings.length; ++i) {
                type = (i==0) ? "outerBoundaryIs" : "innerBoundaryIs";
                ringMember = this.createElementNS(this.gmlns,
                                                  "gml:" + type);
                ringGeom = this.buildGeometry.linearring.apply(this,
                                                                   [rings[i]]);
                ringMember.appendChild(ringGeom);
                gml.appendChild(ringMember);
            }
            return gml;
        }
442676
public static MultiLineString convert(MultiLineString multiLineString, int dimension) {
        int nb = multiLineString.getNumGeometries();
        final LineString[] ls = new LineString[nb];
        for (int i = 0; i < nb; i++) {
            ls[i] = GeometryCoordinateDimension.convert((LineString) multiLineString.getGeometryN(i),dimension);
        }
        return gf.createMultiLineString(ls);
    }
869861
public GeometryExpression<Geometry> geometryN(Integer n) {
        return GeometryExpressions.geometryOperation(SpatialOps.GEOMETRYN, mixin, ConstantImpl.create(n));
    }
697792
function(geometry) {
            var gml = this.createElementNS(this.gmlns, "gml:MultiPolygon");
            var polys = geometry.components;
            var polyMember, polyGeom;
            for(var i=0; i<polys.length; ++i) {
                polyMember = this.createElementNS(this.gmlns,
                                                  "gml:polygonMember");
                polyGeom = this.buildGeometry.polygon.apply(this,
                                                                [polys[i]]);
                polyMember.appendChild(polyGeom);
                gml.appendChild(polyMember);
            }
            return gml;

        }
35672
public static Double computeAspect(Geometry geometry) throws IllegalArgumentException {
        if (geometry == null) {
            return null;
        }
        Vector3D vector = TriMarkers.getSteepestVector(TriMarkers.getNormalVector(TINFeatureFactory.createTriangle(geometry)), TINFeatureFactory.EPSILON);
        if (vector.length() < TINFeatureFactory.EPSILON) {
            return 0d;
        } else {
            Vector2D v = new Vector2D(vector.getX(), vector.getY());
            return measureFromNorth(Math.toDegrees(v.angle()));
        }
    }
617840
protected com.vividsolutions.jts.geom.Geometry toJtsGeometryCollection(Geometry<?> src) {

        com.vividsolutions.jts.geom.Geometry returnGeometry;
        if (src instanceof Point) {
            returnGeometry = toJtsPoint((Point) src);
        } else if (src instanceof LineString) {
            returnGeometry = toJtsLineString((LineString) src);
        } else if (src instanceof Polygon) {
            returnGeometry = toJtsPolygon((Polygon) src);
        } else if (src instanceof MultiPoint) {
            AbstractJtsCodec<com.vividsolutions.jts.geom.MultiPoint, MultiPoint> codec = new MultiPointCodec(this.geometryFactory);
            returnGeometry = codec.fromGeometry((MultiPoint) src);
        } else if (src instanceof MultiLineString) {
            AbstractJtsCodec<com.vividsolutions.jts.geom.MultiLineString, MultiLineString> codec = new MultiLineStringCodec(this.geometryFactory);
            returnGeometry = codec.fromGeometry((MultiLineString) src);
        } else if (src instanceof MultiPolygon) {
            AbstractJtsCodec<com.vividsolutions.jts.geom.MultiPolygon, MultiPolygon> codec = new MultiPolygonCodec(this.geometryFactory);
            returnGeometry = codec.fromGeometry((MultiPolygon) src);
        } else if (src instanceof GeometryCollection) {
            GeometryCollection geometryCollection = (GeometryCollection) src;
            returnGeometry = this.geometryFactory.createGeometryCollection(StreamSupport.stream(geometryCollection.getGeometries().spliterator(), false)
                    .map(this::toJtsGeometryCollection)
                    .toArray(com.vividsolutions.jts.geom.Geometry[]::new));
        } else {
            throw new IllegalArgumentException("Unsupported geometry type: " + src.type());
        }
        return returnGeometry;
    }
849159
public static Geometry reverse3DLine(Geometry geometry, String order) {
        if(geometry == null){
            return null;
        }
        if (geometry instanceof LineString) {
            return reverse3D((LineString) geometry, order);
        } else if (geometry instanceof MultiLineString) {
            return reverse3D((MultiLineString) geometry, order);
        }
        return null;
    }
1309503
function(geometry) {
        var coordinatesNode = this.createElementNS(this.kmlns, "coordinates");
        
        var path;
        var points = geometry.components;
        if(points) {
            // LineString or LinearRing
            var point;
            var numPoints = points.length;
            var parts = new Array(numPoints);
            for(var i=0; i<numPoints; ++i) {
                point = points[i];
                parts[i] = this.buildCoordinates(point);
            }
            path = parts.join(" ");
        } else {
            // Point
            path = this.buildCoordinates(geometry);
        }
        
        var txtNode = this.createTextNode(path);
        coordinatesNode.appendChild(txtNode);
        
        return coordinatesNode;
    }
1130297
public static MultiPolygon convert(MultiPolygon multiPolygon,int dimension) {
        int nb = multiPolygon.getNumGeometries();
        final Polygon[] pl = new Polygon[nb];
        for (int i = 0; i < nb; i++) {
            pl[i] = GeometryCoordinateDimension.convert((Polygon) multiPolygon.getGeometryN(i),dimension);
        }
        return gf.createMultiPolygon(pl);
    }
665394
public GeometryExpression<Geometry> union(Expression<? extends Geometry> geometry) {
        return GeometryExpressions.geometryOperation(SpatialOps.UNION, mixin, geometry);
    }
428884
public Geometry execute(Geometry geometry) {
		if (geometry == null) {
			return null;
		}
		if (geometry instanceof Point) {
			return translate((Point) geometry);
		} else if (geometry instanceof LinearRing) {
			return translate((LinearRing) geometry);
		} else if (geometry instanceof LineString) {
			return translate((LineString) geometry);
		} else if (geometry instanceof Polygon) {
			return translate((Polygon) geometry);
		} else if (geometry instanceof MultiPoint) {
			return translate((MultiPoint) geometry);
		} else if (geometry instanceof MultiLineString) {
			return translate((MultiLineString) geometry);
		} else if (geometry instanceof MultiPolygon) {
			return translate((MultiPolygon) geometry);
		}

		return null;
	}
49175
@Override
	public Geometry toDto(com.vividsolutions.jts.geom.Geometry geometry) throws GeomajasException {
		if (geometry == null) {
			return null;
		}
		try {
			return GeometryConverterService.fromJts(geometry);
		} catch (JtsConversionException jce) {
			throw new GeomajasException(jce, ExceptionCode.CANNOT_CONVERT_GEOMETRY, geometry.getClass().getName());
		}
	}