Removes duplicated coordinates within a geometry.

@param geom
@return
9705
public static Geometry removeCoordinates(Geometry geom) {
        if(geom ==null){
            return null;
        }
        else if (geom.isEmpty()) {
            return geom;
        } else if (geom instanceof Point){
            return geom;        }
         else if (geom instanceof MultiPoint) {
            return removeCoordinates((MultiPoint) geom);
        } else if (geom instanceof LineString) {
            return removeCoordinates((LineString) geom);
        } else if (geom instanceof MultiLineString) {
            return removeCoordinates((MultiLineString) geom);
        } else if (geom instanceof Polygon) {
            return removeCoordinates((Polygon) geom);
        } else if (geom instanceof MultiPolygon) {
            return removeCoordinates((MultiPolygon) geom);
        } else if (geom instanceof GeometryCollection) {
            return removeCoordinates((GeometryCollection) geom);
        }
        return null;
    }
1201294
private static Geometry insertVertexInMultipoint(Geometry g, Point vertexPoint) {
        ArrayList<Point> geoms = new ArrayList<Point>();
        for (int i = 0; i < g.getNumGeometries(); i++) {
            Point geom = (Point) g.getGeometryN(i);
            geoms.add(geom);
        }
        geoms.add(FACTORY.createPoint(new Coordinate(vertexPoint.getX(), vertexPoint.getY())));
        return FACTORY.createMultiPoint(GeometryFactory.toPointArray(geoms));
    }
314200
public static Integer getCoordinateDimension(byte[] geom) throws IOException {
        if (geom == null) {
            return null;
        }
        return GeometryMetaData.getMetaDataFromWKB(geom).dimension;
    }
912425
public static GeometryCollection removeDuplicateCoordinates(GeometryCollection geometryCollection, double tolerance) throws SQLException {
        ArrayList<Geometry> geoms = new ArrayList<>();
        for (int i = 0; i < geometryCollection.getNumGeometries(); i++) {
            Geometry geom = geometryCollection.getGeometryN(i);
            geoms.add(removeDuplicateCoordinates(geom, tolerance));
        }
        return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
    }
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;
    }
947363
public static Geometry force(Geometry geom, int dimension) {
        if (geom instanceof Point) {
            return gf.createPoint(convertSequence(geom.getCoordinates(),dimension));
        } else if (geom instanceof LineString) {
            return gf.createLineString(convertSequence(geom.getCoordinates(),dimension));
        } else if (geom instanceof Polygon) {
            return GeometryCoordinateDimension.convert((Polygon) geom,dimension);
        } else if (geom instanceof MultiPoint) {
            return gf.createMultiPoint(convertSequence(geom.getCoordinates(),dimension));
        } else if (geom instanceof MultiLineString) {
            return GeometryCoordinateDimension.convert((MultiLineString) geom,dimension);
        } else if (geom instanceof MultiPolygon) {
            return GeometryCoordinateDimension.convert((MultiPolygon) geom,dimension);
        } else if (geom instanceof GeometryCollection) {
            return GeometryCoordinateDimension.convert((GeometryCollection)geom,dimension);
        }
        return geom;
    }
102252
public Coordinate getCoordinate(Geometry geometry) {
		LineString lineString = getLineString(geometry);
		if (lineString != null && coordinateIndex >= 0) {
			return lineString.getCoordinateN(coordinateIndex);
		}
		return null;
	}
719511
public static String toGML(Geometry geom) {
        if (geom == null) {
            return null;
        }
        int srid = geom.getSRID();
        GMLWriter gmlw = new GMLWriter();
        if (srid != -1 || srid != 0) {
            gmlw.setSrsName("EPSG:" + geom.getSRID());
        }
        return gmlw.write(geom);
    }
912314
public static GeometryCollection removeCoordinates(GeometryCollection g) {
        ArrayList<Geometry> geoms = new ArrayList<Geometry>();
        for (int i = 0; i < g.getNumGeometries(); i++) {
            Geometry geom = g.getGeometryN(i);
            geoms.add(removeCoordinates(geom));
        }
        return FACTORY.createGeometryCollection(GeometryFactory.toGeometryArray(geoms));
    }
808557
public void setGeometries(Geometry[] geometries) {
		List<Coordinate> coordinates = getCoordinates(geometries);
		sortedX = sortX(coordinates);
		sortedY = sortY(coordinates);
	}
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;
	}
841083
public static LineString removeCoordinates(LineString g) {
        Coordinate[] coords = CoordinateUtils.removeDuplicatedCoordinates(g.getCoordinates(), false);
        return FACTORY.createLineString(coords);
    }
442252
public static Boolean geomEquals(Geometry a, Geometry b) {
        if(a==null || b==null) {
            return null;
        }
        return a.equals(b);
    }
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]);
        }
1123071
public static VectorTile.Tile.GeomType toGeomType(Geometry geometry) {
        VectorTile.Tile.GeomType result = VectorTile.Tile.GeomType.UNKNOWN;

        if(geometry instanceof Point
                || geometry instanceof MultiPoint) {
            result = VectorTile.Tile.GeomType.POINT;

        } else if(geometry instanceof LineString
                || geometry instanceof MultiLineString) {
            result = VectorTile.Tile.GeomType.LINESTRING;

        } else if(geometry instanceof Polygon
                || geometry instanceof MultiPolygon) {
            result = VectorTile.Tile.GeomType.POLYGON;
        }

        return result;
    }
902675
public static boolean isSimple(Geometry geometry) {
		if (isEmpty(geometry)) {
			return true;
		}
		if (geometry.getGeometries() != null) {
			for (Geometry child : geometry.getGeometries()) {
				if (!isSimple(child)) {
					return false;
				}
				if (Geometry.MULTI_LINE_STRING.equals(geometry.getGeometryType())) {
					for (Geometry child2 : geometry.getGeometries()) {
						if (child != child2 && intersects(child, child2)) {
							return false;
						}
					}
				}
			}
		}
		if (geometry.getCoordinates() != null) {
			List<Coordinate> coords1 = new ArrayList<Coordinate>();
			List<Coordinate> coords2 = new ArrayList<Coordinate>();
			getAllCoordinates(geometry, coords1);
			getAllCoordinates(geometry, coords2);

			// Search for any intersection:
			if (coords1.size() > 1 && coords2.size() > 1) {
				for (int i = 0; i < coords2.size() - 1; i++) {
					for (int j = 0; j < coords1.size() - 1; j++) {
						if ((i != j)
								&& MathService.intersectsLineSegment(coords2.get(i), coords2.get(i + 1),
										coords1.get(j), coords1.get(j + 1))) {
							return false;
						}
					}
				}
			}
		}
		return true;
	}
471081
private OGCGeometry simplifyBunch_(GeometryCursor gc) {
		// Combines geometries into multipoint, polyline, and polygon types,
		// simplifying them and unioning them,
		// then produces OGCGeometry from the result.
		// Can produce OGCConcreteGoemetryCollection
		MultiPoint dstMultiPoint = null;
		ArrayList<Geometry> dstPolylines = new ArrayList<Geometry>();
		ArrayList<Geometry> dstPolygons = new ArrayList<Geometry>();
		for (com.esri.core.geometry.Geometry g = gc.next(); g != null; g = gc
				.next()) {
			switch (g.getType()) {
			case Point:
				if (dstMultiPoint == null)
					dstMultiPoint = new MultiPoint();
				dstMultiPoint.add((Point) g);
				break;
			case MultiPoint:
				if (dstMultiPoint == null)
					dstMultiPoint = new MultiPoint();
				dstMultiPoint.add((MultiPoint) g, 0, -1);
				break;
			case Polyline:
				dstPolylines.add((Polyline) g.copy());
				break;
			case Polygon:
				dstPolygons.add((Polygon) g.copy());
				break;
			default:
				throw new UnsupportedOperationException();
			}
		}

		ArrayList<Geometry> result = new ArrayList<Geometry>(3);
		if (dstMultiPoint != null) {
			Geometry resMP = OperatorSimplifyOGC.local().execute(dstMultiPoint,
					esriSR, true, null);
			result.add(resMP);
		}

		if (dstPolylines.size() > 0) {
			if (dstPolylines.size() == 1) {
				Geometry resMP = OperatorSimplifyOGC.local().execute(
						dstPolylines.get(0), esriSR, true, null);
				result.add(resMP);
			} else {
				GeometryCursor res = OperatorUnion.local().execute(
						new SimpleGeometryCursor(dstPolylines), esriSR, null);
				Geometry resPolyline = res.next();
				Geometry resMP = OperatorSimplifyOGC.local().execute(
						resPolyline, esriSR, true, null);
				result.add(resMP);
			}
		}

		if (dstPolygons.size() > 0) {
			if (dstPolygons.size() == 1) {
				Geometry resMP = OperatorSimplifyOGC.local().execute(
						dstPolygons.get(0), esriSR, true, null);
				result.add(resMP);
			} else {
				GeometryCursor res = OperatorUnion.local().execute(
						new SimpleGeometryCursor(dstPolygons), esriSR, null);
				Geometry resPolygon = res.next();
				Geometry resMP = OperatorSimplifyOGC.local().execute(
						resPolygon, esriSR, true, null);
				result.add(resMP);
			}
		}

		return OGCGeometry.createFromEsriCursor(
				new SimpleGeometryCursor(result), esriSR);
	}