Creates simple arrow polygons in the direction of the coordinates.

@param geometries the geometries (lines and polygons) for which to create the arrows.
@return the list of polygon arrows.
481012
public static List<Polygon> createSimpleDirectionArrow( Geometry... geometries ) {
        List<Polygon> polygons = new ArrayList<>();
        for( Geometry geometry : geometries ) {
            for( int i = 0; i < geometry.getNumGeometries(); i++ ) {
                Geometry geometryN = geometry.getGeometryN(i);
                if (geometryN instanceof LineString) {
                    LineString line = (LineString) geometryN;
                    polygons.addAll(makeArrows(line));
                } else if (geometryN instanceof Polygon) {
                    Polygon polygonGeom = (Polygon) geometryN;
                    LineString exteriorRing = polygonGeom.getExteriorRing();
                    polygons.addAll(makeArrows(exteriorRing));
                    int numInteriorRing = polygonGeom.getNumInteriorRing();
                    for( int j = 0; j < numInteriorRing; j++ ) {
                        LineString interiorRingN = polygonGeom.getInteriorRingN(j);
                        polygons.addAll(makeArrows(interiorRingN));
                    }
                }
            }
        }
        return polygons;
    }
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;
        }
113593
public static List<String> getDimensions(Map<String, String> fetchDimensions) {
        return new ArrayList<>(fetchDimensions.keySet());
    }
554043
public List<Polygon> polygons() {
    List<List<List<Point>>> coordinates = coordinates();
    List<Polygon> polygons = new ArrayList<>(coordinates.size());
    for (List<List<Point>> points : coordinates) {
      polygons.add(Polygon.fromLngLats(points));
    }
    return polygons;
  }
429294
@Api
	public void setGeometry(List<Geometry> geometries) {
		if (geometries.size() == 0) {
			Notify.info(messages.geometricSearchWidgetSelectionSearchNothingSelected());
		} else {
			Integer buffer = (Integer) spiBuffer.getValue();
			if (buffer != 0) {
				SearchCommService.mergeAndBufferGeometries(geometries, buffer, new DataCallback<Geometry[]>() {
					public void execute(Geometry[] result) {
						updateGeometry(geometry, result[1]);
						geometry = result[1];
					}
				});
			} else {
				SearchCommService.mergeGeometries(geometries, new DataCallback<Geometry>() {
					public void execute(Geometry result) {
						updateGeometry(geometry, result);
						geometry = result;
					}
				});
			}
		}
	}
695337
public static GeometryCollection getHoles(Geometry geom) throws SQLException {
        if (geom != null) {
            if (geom.getDimension() >= 2) {
                ArrayList<Geometry> holes = new ArrayList<Geometry>();
                for (int i = 0; i < geom.getNumGeometries(); i++) {
                    Geometry subgeom = geom.getGeometryN(i);
                    if (subgeom instanceof Polygon) {
                        Polygon polygon = (Polygon) subgeom;
                        for (int j = 0; j < polygon.getNumInteriorRing(); j++) {
                            holes.add(GEOMETRY_FACTORY.createPolygon(
                                    GEOMETRY_FACTORY.createLinearRing(
                                            polygon.getInteriorRingN(j).getCoordinates()), null));
                        }
                    }
                }
                return GEOMETRY_FACTORY.createGeometryCollection(
                        holes.toArray(new Geometry[0]));
            } else {
                return GEOMETRY_FACTORY.createGeometryCollection(null);
            }
        }
        return null;
    }
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;
	}
1253252
static private Vector3f[] copyVertices(Vector3f[] vertices) {
        if (vertices == null) {
            return null;
        }
        Vector3f[] copy = new Vector3f[vertices.length];
        for (int i = 0; i < vertices.length; ++i) {
            copy[i] = new Vector3f(vertices[i]);
        }
        return copy;
    }
837751
public Geometry execute(Geometry geometry) {
		if (geometry == null) {
			return null;
		}
		if (geometry instanceof LinearRing) {
			if (coordIndex <= 0) {
				coordIndex = 0;
			} else if (coordIndex > geometry.getNumPoints() - 2) {
				coordIndex = geometry.getNumPoints() - 2;
			}
			Coordinate[] coordinates = new Coordinate[geometry.getNumPoints()];
			for (int i = 0; i < coordinates.length; i++) {
				Coordinate coordinate = geometry.getCoordinates()[i];
				if (i == coordIndex) {
					coordinates[i] = new Coordinate(coordinate.getX() + translateX, coordinate.getY() + translateY);
				} else if (i == geometry.getNumPoints() - 1) {
					coordinates[i] = coordinates[0];
				} else {
					coordinates[i] = coordinate;
				}
			}
			return geometry.getGeometryFactory().createLinearRing(coordinates);
		} else if (geometry instanceof LineString) {
			if (coordIndex <= 0) {
				coordIndex = 0;
			} else if (coordIndex > geometry.getNumPoints() - 1) {
				coordIndex = geometry.getNumPoints() - 1;
			}
			Coordinate[] coordinates = new Coordinate[geometry.getNumPoints()];
			for (int i = 0; i < coordinates.length; i++) {
				Coordinate coordinate = geometry.getCoordinates()[i];
				if (i == coordIndex) {
					coordinates[i] = new Coordinate(coordinate.getX() + translateX, coordinate.getY() + translateY);
				} else {
					coordinates[i] = geometry.getCoordinates()[i];
				}
			}
			return geometry.getGeometryFactory().createLineString(coordinates);
		}
		return null;
	}
72645
public static List<WayDataBlock> toWayDataBlockList(Geometry geometry) {
        List<WayDataBlock> res = new ArrayList<>();
        if (geometry instanceof MultiPolygon) {
            MultiPolygon mp = (MultiPolygon) geometry;
            for (int i = 0; i < mp.getNumGeometries(); i++) {
                Polygon p = (Polygon) mp.getGeometryN(i);
                List<Integer> outer = toCoordinateList(p.getExteriorRing());
                if (outer.size() / 2 > 0) {
                    List<List<Integer>> inner = new ArrayList<>();
                    for (int j = 0; j < p.getNumInteriorRing(); j++) {
                        List<Integer> innr = toCoordinateList(p.getInteriorRingN(j));
                        if (innr.size() / 2 > 0) {
                            inner.add(innr);
                        }
                    }
                    res.add(new WayDataBlock(outer, inner));
                }
            }
        } else if (geometry instanceof Polygon) {
            Polygon p = (Polygon) geometry;
            List<Integer> outer = toCoordinateList(p.getExteriorRing());
            if (outer.size() / 2 > 0) {
                List<List<Integer>> inner = new ArrayList<>();
                for (int i = 0; i < p.getNumInteriorRing(); i++) {
                    List<Integer> innr = toCoordinateList(p.getInteriorRingN(i));
                    if (innr.size() / 2 > 0) {
                        inner.add(innr);
                    }
                }
                res.add(new WayDataBlock(outer, inner));
            }
        } else if (geometry instanceof MultiLineString) {
            MultiLineString ml = (MultiLineString) geometry;
            for (int i = 0; i < ml.getNumGeometries(); i++) {
                LineString l = (LineString) ml.getGeometryN(i);
                List<Integer> outer = toCoordinateList(l);
                if (outer.size() / 2 > 0) {
                    res.add(new WayDataBlock(outer, null));
                }
            }
        } else if (geometry instanceof LinearRing || geometry instanceof LineString) {
            List<Integer> outer = toCoordinateList(geometry);
            if (outer.size() / 2 > 0) {
                res.add(new WayDataBlock(outer, null));
            }
        } else if (geometry instanceof GeometryCollection) {
            GeometryCollection gc = (GeometryCollection) geometry;
            for (int i = 0; i < gc.getNumGeometries(); i++) {
                List<WayDataBlock> recursiveResult = toWayDataBlockList(gc.getGeometryN(i));
                for (WayDataBlock wayDataBlock : recursiveResult) {
                    List<Integer> outer = wayDataBlock.getOuterWay();
                    if (outer.size() / 2 > 0) {
                        res.add(wayDataBlock);
                    }
                }
            }
        }

        return res;
    }
1010133
public static Polygon makePolygon(Geometry shell, Geometry... holes) throws IllegalArgumentException {
        if(shell == null) {
            return null;
        }
        LinearRing outerLine = checkLineString(shell);
        LinearRing[] interiorlinestrings = new LinearRing[holes.length];
        for (int i = 0; i < holes.length; i++) {
            interiorlinestrings[i] = checkLineString(holes[i]);
        }
        return shell.getFactory().createPolygon(outerLine, interiorlinestrings);
    }
1357429
public static ArrayList<SegmentString> getSegments(Geometry inputLines, Geometry clipper) {
        ArrayList<SegmentString> segments = new ArrayList<SegmentString>();        
        addGeometryToSegments(inputLines, 0, segments);        
        addGeometryToSegments(clipper, 1, segments);
        return segments;
    }
1160294
private static Collection<Polygon> polygonWithLineSplitter(Polygon polygon, LineString lineString) throws SQLException {
        Collection<Polygon> polygons = splitPolygonizer(polygon, lineString);
        if (polygons != null && polygons.size() > 1) {
            List<Polygon> pols = new ArrayList<Polygon>();
            for (Polygon pol : polygons) {
                if (polygon.contains(pol.getInteriorPoint())) {
                    pols.add(pol);
                }
            }
            return pols;
        }
        return null;
    }
813081
public void writeGeometries( Geometry[] geometries ) throws IOException {
        File file = new File(path);
        RandomAccessFile raf = null;
        try {
            raf = new RandomAccessFile(file, "rw");

            int major = JTSVersion.MAJOR;
            int minor = JTSVersion.MINOR;

            raf.writeChars("jts");
            raf.writeInt(major);
            raf.writeInt(minor);

            long geometriesStart = INDEX_ADDRESS_POSITION + INDEX_ADDRESS_SIZE + INDEX_LENGTH_SIZE;
            raf.seek(geometriesStart);
            System.out.println("geometriesStart: " + geometriesStart);

            long fileIndex = geometriesStart;
            STRtree tree = new STRtree(geometries.length);
            for( int i = 0; i < geometries.length; i++ ) {
                Geometry geometry = geometries[i];

                if (geometry.isEmpty()) {
                    continue;
                }
                Envelope envelope = geometry.getEnvelopeInternal();

                byte[] geomBytes = serialize(geometry);
                raf.write(geomBytes);

                /*
                 * the tree contains the envelope of a geometry
                 * and the array with the exact position in the file where the 
                 * geometry bytes start + the length. 
                 */
                tree.insert(envelope, new long[]{fileIndex, geomBytes.length});

                fileIndex = fileIndex + geomBytes.length;
                System.out.println("geom: " + i + " finished at: " + fileIndex);
            }

            raf.seek(INDEX_ADDRESS_POSITION);
            raf.writeLong(fileIndex);

            System.out.println("INDEX_ADDRESS_POSITION: " + fileIndex);

            /*
             * serialize index
             */
            byte[] treeBytes = serialize(tree);

            long treeSize = treeBytes.length;
            raf.seek(fileIndex);
            raf.write(treeBytes, 0, (int) treeSize);

            System.out.println("treeSize: " + treeSize);

            raf.seek(INDEX_ADDRESS_POSITION + INDEX_ADDRESS_SIZE);
            raf.writeLong(treeSize);

            long length = raf.length();
            System.out.println(length);

        } finally {
            System.out.println("close");
            if (raf != null)
                raf.close();
        }
    }
248089
private void buildVertexes()
	{
		vertexes.clear();
		if (controlPoints.size() == 0)
			return;

		double step = 1D / (precision + 1);
		double t = 0;
		vertexes.add(controlPoints.get(0));
		for (int i = 1; i <= precision; i++)
		{
			t = i * step;
			vertexes.add(i, interpolateAll(controlPoints, controlPoints.size() - 1, 0, t));
		}
		vertexes.add(controlPoints.get(controlPoints.size() - 1));

		dirty = false;
	}
764913
public List<Triangle> triangulate(List<Vector3> points) {
		init(points.size());

		Set<Vector3> vertices = new TreeSet<Vector3>(new PointComparator());

		bbMin = new Vector3(points.get(0));
		bbMax = new Vector3(points.get(0));

		//Insert Points
		for (Vector3 point:points) {
			this.insertPoint(vertices, point);
		}

		List<Triangle> triangles = null;

		if (modCount != modCount2 && vertices.size() > 2) {
			triangles = generateTriangles();
		}

		return triangles;
	}
355732
public static void reproject( CoordinateReferenceSystem from, CoordinateReferenceSystem to, Object[] geometries )
            throws Exception {
        MathTransform mathTransform = CRS.findMathTransform(from, to);

        for( int i = 0; i < geometries.length; i++ ) {
            geometries[i] = JTS.transform((Geometry) geometries[i], mathTransform);
        }
    }