Class GMLFilterGeometry

  • All Implemented Interfaces:
    GMLHandlerGeometry, ContentHandler, DTDHandler, EntityResolver, ErrorHandler, XMLFilter, XMLReader

    public class GMLFilterGeometry
    extends XMLFilterImpl
    implements GMLHandlerGeometry
    LEVEL2 saxGML4j GML filter: translates coordinates and GML events into OGC simple types.

    This filter simply reads in the events and coordinates passed to it by its GMLFilterDocument child and converts them into JTS objects. Note that it passes through anything not specifically sent to it by GMLFilterDocument (i.e. more or less everything not in geometry.xsd). The parent of this filter must implement GMLHandlerJTS in order to receive the JTS objects passed by this filter.

    Author:
    Rob Hranac, Vision for New York
    • Constructor Summary

      Constructors 
      Constructor Description
      GMLFilterGeometry​(GMLHandlerJTS parent)
      Constructor with parent, which must implement GMLHandlerJTS.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void characters​(char[] ch, int start, int length)
      Reads the only internal characters read by pure GML parsers, which are coordinates.
      void endElement​(String namespaceURI, String localName, String qName)
      Checks for GML element end and - if not a coordinates element - sends it directly on down the chain to the appropriate parent handler.
      void geometryEnd​(String localName)
      Manages the end of a new main or sub geometry.
      void geometryStart​(String localName, Attributes atts)
      Manages the start of a new main or sub geometry.
      void geometrySub​(String localName)
      Manages a sub geometry, which simply means always pass it to the current content handler as a sub.
      void gmlCoordinates​(double x, double y)
      Gets a coordinate from the child and passes it to the current handler as an add request.
      void gmlCoordinates​(double x, double y, double z)
      Gets a coordinate from the child and passes it to the current handler as an add request.
      void startElement​(String namespaceURI, String localName, String qName, Attributes atts)
      Checks for GML element start and - if not a coordinates element - sends it directly on down the chain to the appropriate parent handler.
      • Methods inherited from class XMLFilterImpl

        endDocument, endPrefixMapping, error, fatalError, getContentHandler, getDTDHandler, getEntityResolver, getErrorHandler, getFeature, getParent, getProperty, ignorableWhitespace, notationDecl, parse, parse, processingInstruction, resolveEntity, setContentHandler, setDocumentLocator, setDTDHandler, setEntityResolver, setErrorHandler, setFeature, setParent, setProperty, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface ContentHandler

        endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping
    • Constructor Detail

      • GMLFilterGeometry

        public GMLFilterGeometry​(GMLHandlerJTS parent)
        Constructor with parent, which must implement GMLHandlerJTS.
        Parameters:
        parent - The parent of this filter.
    • Method Detail

      • geometryStart

        public void geometryStart​(String localName,
                                  Attributes atts)
                           throws SAXException
        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.
        Specified by:
        geometryStart in interface GMLHandlerGeometry
        Parameters:
        localName - The local name of the geometry, which corresponds to an OGC simple feature type.
        atts - The attributes of the geometry, including SRID, etc.
        Throws:
        SAXException - parser error.
      • geometryEnd

        public void geometryEnd​(String localName)
                         throws SAXException
        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.
        Specified by:
        geometryEnd in interface GMLHandlerGeometry
        Parameters:
        localName - The local name of the geometry, which corresponds to an OGC simple feature type.
        Throws:
        SAXException - parser error.
      • geometrySub

        public void geometrySub​(String localName)
                         throws SAXException
        Manages a sub geometry, which simply means always pass it to the current content handler as a sub.
        Specified by:
        geometrySub in interface GMLHandlerGeometry
        Parameters:
        localName - The local name of the geometry, which corresponds to an OGC simple feature type.
        Throws:
        SAXException - parser error.
      • gmlCoordinates

        public void gmlCoordinates​(double x,
                                   double y)
                            throws SAXException
        Gets a coordinate from the child and passes it to the current handler as an add request.
        Specified by:
        gmlCoordinates in interface GMLHandlerGeometry
        Parameters:
        x - The X coordinate of the received coordinate.
        y - The Y coordinate of the received coordinate.
        Throws:
        SAXException - parser error.
      • gmlCoordinates

        public void gmlCoordinates​(double x,
                                   double y,
                                   double z)
                            throws SAXException
        Gets a coordinate from the child and passes it to the current handler as an add request.
        Specified by:
        gmlCoordinates in interface GMLHandlerGeometry
        Parameters:
        x - The X coordinate of the received coordinate.
        y - The Y coordinate of the received coordinate.
        z - The Z coordinate of the received coordinate.
        Throws:
        SAXException - parser error.
      • startElement

        public void startElement​(String namespaceURI,
                                 String localName,
                                 String qName,
                                 Attributes atts)
                          throws SAXException
        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.
        Specified by:
        startElement in interface ContentHandler
        Overrides:
        startElement in class XMLFilterImpl
        Parameters:
        namespaceURI - The namespace of the element.
        localName - The local name of the element.
        qName - The full name of the element, including namespace prefix.
        atts - The element attributes.
        Throws:
        SAXException - Some parsing error occurred while reading coordinates.
      • characters

        public void characters​(char[] ch,
                               int start,
                               int length)
                        throws SAXException
        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.
        Specified by:
        characters in interface ContentHandler
        Overrides:
        characters in class XMLFilterImpl
        Parameters:
        ch - Raw coordinate string from the GML document.
        start - Beginning character position of raw coordinate string.
        length - Length of the character string.
        Throws:
        SAXException - Some parsing error occurred while reading coordinates.
      • endElement

        public void endElement​(String namespaceURI,
                               String localName,
                               String qName)
                        throws SAXException
        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.
        Specified by:
        endElement in interface ContentHandler
        Overrides:
        endElement in class XMLFilterImpl
        Parameters:
        namespaceURI - The namespace of the element.
        localName - The local name of the element.
        qName - The full name of the element, including namespace prefix.
        Throws:
        SAXException - Some parsing error occurred while reading coordinates.