Class GMLFilterDocument

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

    public class GMLFilterDocument
    extends XMLFilterImpl
    LEVEL1 saxGML4j GML filter: Sends basic alerts for GML types to GMLFilterGeometry.

    This filter separates and passes GML events to a GMLHandlerGeometry. The main simplification that it performs is to pass along coordinates as an abstracted method call, regardless of their notation in the GML (Coord vs. Coordinates). This call turns the coordinates into doubles and makes sure that it distinguishes between 2 and 3 value coordinates.

    The filter also handles some more subtle processing, including handling different delimiters (decimal, coordinate, tuple) that may be used by more outlandish GML generators.

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

      • GMLFilterDocument

        public GMLFilterDocument​(GMLHandlerGeometry parent)
        Constructor with parent.
        Parameters:
        parent - Parent of the filter: must implement GMLHandlerGeometry.
    • Method Detail

      • 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.

        Modified by Sean Geoghegan to create new StringBuffers when entering a coord or coordinate element.

        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.

        Modified by Sean Geoghegan to append character data to buffer when inside a coordinate or coord element. SAX doesn't guarentee that all the character data of an element will be passed to the character method in one call, it may be split up into chunks.

        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.

        Modified by Sean Geoghegan. When we reach the end of a coord or coordinate element, then the buffer is passed to the handler for processing.

        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.