private String geometrySignature(Geometry geom) { if (geom == null) return ""; String sig = geom.getGeometryType(); if (geom instanceof GeometryCollection) { sig += "[" + geom.getNumGeometries() + "]"; } else { sig += "(" + geom.getNumPoints() + ")"; } return sig; }
/** * Returns the nth point of a line. * * @param node xml element containing gml object(s) * @param number index of i-th point * @return n-th point as a gml element * @throws QueryException query exception */ @Deterministic public ANode pointN(final ANode node, final Int number) throws QueryException { final Geometry geo = geo(node, Q_GML_LINEARRING, Q_GML_LINESTRING); if (geo == null && checkGeo(node) != null) throw GeoErrors.geoType(node.qname().local(), "Line"); final int max = geo.getNumPoints(); final long n = number.itr(); if (n < 1 || n > max) throw GeoErrors.outOfRangeIdx(number); return gmlWriter(((LineString) geo).getPointN((int) n - 1)); }
private int calculateSize(Geometry geom, boolean includeSrid) { int size = 1 + ByteBuffer.UINT_SIZE; // size for order byte + type field if (geom.getSRID() > 0 && includeSrid) size += 4; if (geom instanceof GeometryCollection) { size += sizeOfGeometryCollection((GeometryCollection) geom); } else if (geom instanceof Polygon) { size += getPolygonSize((Polygon) geom); } else if (geom instanceof Point) { size += getPointByteSize(geom); } else if (geom instanceof PolyHedralSurface) { size += getPolyHedralSurfaceSize((PolyHedralSurface) geom); } else { size += ByteBuffer.UINT_SIZE; // to hold number of points size += getPointByteSize(geom) * geom.getNumPoints(); } return size; }