/** * Manages a sub geometry, which simply means always pass it to the current content handler as a * sub. * * @param localName The local name of the geometry, which corresponds to an OGC simple feature * type. * @throws SAXException parser error. */ public void geometrySub(String localName) throws SAXException { currentHandler.subGeometry(localName, currentHandler.GEOMETRY_SUB); }
/** * Adds a coordinate to the current LinearRing. * * @param coordinate Name of sub geometry located. */ public void addCoordinate(Coordinate coordinate) { currentHandler.addCoordinate(coordinate); }
/** * Adds a coordinate to the current internal (sub) geometry. * * @param coordinate The coordinate. */ public void addCoordinate(Coordinate coordinate) { currentHandler.addCoordinate(coordinate); }
returnValue = new SubHandlerPoint(); } else if (type.equals("LineString")) { returnValue = new SubHandlerLineString(); } else if (type.equals("LinearRing")) { returnValue = new SubHandlerLinearRing(); } else if (type.equals("Polygon")) { returnValue = new SubHandlerPolygon(); } else if (type.equals("Box")) { returnValue = new SubHandlerBox(); } else if (BASE_GEOMETRY_TYPES.contains(type)) { returnValue = new SubHandlerMulti(); } else {
/** * Manages the end of a new main or sub geometry. This method looks at the status of the current * handler and either returns the finished JTS object to its parent or passes the element end * notification along to the current handler as a sub geometry notice. * * @param localName The local name of the geometry, which corresponds to an OGC simple feature * type. * @throws SAXException parser error. */ public void geometryEnd(String localName) throws SAXException { if (currentHandler.isComplete(localName)) { parent.geometry(currentHandler.create(geometryFactory)); currentHandler = null; } else { currentHandler.subGeometry(localName, currentHandler.GEOMETRY_END); } }
/** * Manages the start of a new main or sub geometry. This method looks at the status of the * current handler and either returns a new sub-handler (if the last one was successfully * returned already) or passes the element start notification along to the current handler as a * sub geometry notice. * * @param localName The local name of the geometry, which corresponds to an OGC simple feature * type. * @param atts The attributes of the geometry, including SRID, etc. * @throws SAXException parser error. */ public void geometryStart(String localName, org.xml.sax.Attributes atts) throws SAXException { String srs = null; for (int i = 0; i < atts.getLength(); i++) { final String NAME = atts.getQName(i); if ("srs".equalsIgnoreCase(NAME)) { srs = atts.getValue(i); } } if (currentHandler == null) { currentHandler = handlerFactory.create(localName); } else { currentHandler.subGeometry(localName, currentHandler.GEOMETRY_START); } currentHandler.setSRS(srs); }
contentHandler.setEntityResolver(entityResolver); FilterFilter filterParser = new FilterFilter(contentHandler, null); GMLFilterGeometry geometryFilter = new GMLFilterGeometry(filterParser); GMLFilterDocument documentFilter = new GMLFilterDocument(geometryFilter);
currentHandler = handlerFactory.create(internalType); } else if (type == GEOMETRY_END) { geometries.add(currentHandler.create(geometryFactory)); } else if (type == GEOMETRY_SUB) { currentHandler.subGeometry(message, type); currentHandler.subGeometry(message, type); LOGGER.fine(internalType + " != " + message);
if (coordinateReader.insideCoordinates()) { buffer.append(rawCoordinates); } else if (coordinateReader.insideCoord()) { buffer.append(rawCoordinates); parent.characters(ch, start, length);
/** * Generates the point. * * @param geometryFactory Geometry factory to be used to create the point. * @return Created Point. */ public Geometry create(GeometryFactory geometryFactory) { Point point = geometryFactory.createPoint(coordinate); point.setUserData(getSRS()); point.setSRID(getSRID()); return point; } }
/** * Create the LineString. * * @param geometryFactory The geometry factory needed to do the build. * @return JTS LineString geometry. */ public Geometry create(GeometryFactory geometryFactory) { Coordinate[] coords = (Coordinate[]) coordinateList.toArray(new Coordinate[coordinateList.size()]); LineString lineString = geometryFactory.createLineString(coords); lineString.setUserData(getSRS()); lineString.setSRID(getSRID()); return lineString; } }
/** * Create the LinearRing. * * @param geometryFactory The geometry factory used for the build. * @return LinearRing geometry created. */ public Geometry create(GeometryFactory geometryFactory) { try { Coordinate[] coords = (Coordinate[]) coordinateList.toArray(new Coordinate[coordinateList.size()]); LinearRing ring = geometryFactory.createLinearRing(coords); ring.setUserData(getSRS()); ring.setSRID(getSRID()); return ring; } catch (TopologyException e) { LOGGER.log(Level.FINE, "Caught Topology exception in GMLLinearRingHandler", e); return null; } } }
/** * Sets an entrance into a coordinates element. * * @param isInside Sets whether or not we are inside a coordinates tag. * @param atts Passes the coordinates tag attributes. */ public void insideCoordinates(boolean isInside, org.xml.sax.Attributes atts) { this.insideCoordinates(isInside); }
/** * Reads the only internal characters read by pure GML parsers, which are coordinates. These * coordinates are sent to the coordinates reader class which interprets them appropriately, * depending on its current state. * * @param ch Raw coordinate string from the GML document. * @param start Beginning character position of raw coordinate string. * @param length Length of the character string. * @throws SAXException Some parsing error occurred while reading coordinates. */ public void characters(char[] ch, int start, int length) throws SAXException { parent.characters(ch, start, length); }
/** * Checks for GML element end and - if not a coordinates element - sends it directly on down the * chain to the appropriate parent handler. If it is a coordinates (or coord) element, it uses * internal methods to set the current state of the coordinates reader appropriately. * * @param namespaceURI The namespace of the element. * @param localName The local name of the element. * @param qName The full name of the element, including namespace prefix. * @throws SAXException Some parsing error occurred while reading coordinates. */ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { parent.endElement(namespaceURI, localName, qName); } }
/** * Checks for GML element start and - if not a coordinates element - sends it directly on down * the chain to the appropriate parent handler. If it is a coordinates (or coord) element, it * uses internal methods to set the current state of the coordinates reader appropriately. * * @param namespaceURI The namespace of the element. * @param localName The local name of the element. * @param qName The full name of the element, including namespace prefix. * @param atts The element attributes. * @throws SAXException Some parsing error occurred while reading coordinates. */ public void startElement( String namespaceURI, String localName, String qName, org.xml.sax.Attributes atts) throws SAXException { parent.startElement(namespaceURI, localName, qName, atts); }
/** * Sets an entrance into a coord element. * * @param isInside Sets whether or not we are inside a coord tag. * @throws SAXException if error occurs in reading */ public void insideCoord(boolean isInside) throws SAXException { // if entering coord tag, simply set our internal flag for this if (isInside) { insideOuterFlag = INSIDE_COORD; } else { // if leaving coord tag, send coordinates to parent and // set all internal values to null equivalent. // if coordinates exist, send on down the filter chain // otherwise, throw an exception if ((!x.isNaN()) && (!y.isNaN()) && (z.isNaN())) { parent.gmlCoordinates(x.doubleValue(), y.doubleValue()); } else if ((!x.isNaN()) && (!y.isNaN()) && (!z.isNaN())) { parent.gmlCoordinates(x.doubleValue(), y.doubleValue(), z.doubleValue()); } // else { x = new Double(Double.NaN); y = new Double(Double.NaN); z = new Double(Double.NaN); insideOuterFlag = NOT_INSIDE; } }
/** * Manages the start of a new main or sub geometry. This method looks at the status of the * current handler and either returns a new sub-handler (if the last one was successfully * returned already) or passes the element start notification along to the current handler as a * sub geometry notice. * * @param geometry The geometry from the child. */ public void geometry(Geometry geometry) { // insideGeometry = true; // _log.debug("adding geometry with name "+attName); if (insideFeature) { if (attName.equals("")) { attributeNames.addElement("geometry"); } else { attributeNames.addElement(attName); } attributes.addElement(geometry); endAttribute(); // currentFeature.setGeometry(geometry); } // else { // parent.geometry(geometry); // } }
/** * Gets a coordinate from the child and passes it to the current handler as an add request. * * @param x The X coordinate of the received coordinate. * @param y The Y coordinate of the received coordinate. * @throws SAXException parser error. */ public void gmlCoordinates(double x, double y) throws SAXException { currentHandler.addCoordinate(new org.locationtech.jts.geom.Coordinate(x, y)); }
/** * Gets a coordinate from the child and passes it to the current handler as an add request. * * @param x The X coordinate of the received coordinate. * @param y The Y coordinate of the received coordinate. * @param z The Z coordinate of the received coordinate. * @throws SAXException parser error. */ public void gmlCoordinates(double x, double y, double z) throws SAXException { currentHandler.addCoordinate(new org.locationtech.jts.geom.Coordinate(x, y, z)); }