Class GMLWriter


  • public class GMLWriter
    extends Object
    Helper class writing out GML elements and coordinates. Geared towards efficiency, write out elements and ordinate lists with the minimim amount of garbage generation
    Author:
    Andrea Aime - GeoSolutions
    • Constructor Summary

      Constructors 
      Constructor Description
      GMLWriter​(ContentHandler delegate, NamespaceSupport namespaces, int numDecimals, boolean forceDecimal, boolean padWithZeros, String gmlPrefix)
      Create a new content handler
      GMLWriter​(ContentHandler delegate, NamespaceSupport namespaces, int numDecimals, boolean forceDecimal, boolean padWithZeros, String gmlPrefix, boolean encodeMeasures)
      Create a new content handler
      GMLWriter​(ContentHandler delegate, NamespaceSupport namespaces, int numDecimals, boolean forceDecimal, String gmlPrefix)
      Create a new content handler
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void coordinates​(CoordinateSequence cs)
      Writes a GML2 coordinates element
      void endDocument()  
      void endElement​(QualifiedName qn)  
      void endPrefixMapping​(String prefix)  
      void ordinate​(double x)
      Writes a single ordinate, without wrapping it inside any element
      void position​(double x, double y, double z)
      Writes a single x/y position, without wrapping it in any element
      void position​(CoordinateSequence coordinates)
      Encodes the provided coordinates sequence, if encoding of measures is enabled this method will encode all the available ordinates.
      void posList​(CoordinateSequence coordinateSequence)
      Write a GML3 posList
      void setDocumentLocator​(Locator locator)  
      void startDocument()  
      void startElement​(QualifiedName qn, Attributes atts)  
      void startPrefixMapping​(String prefix, String uri)  
      • Methods inherited from class Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GMLWriter

        public GMLWriter​(ContentHandler delegate,
                         NamespaceSupport namespaces,
                         int numDecimals,
                         boolean forceDecimal,
                         String gmlPrefix)
        Create a new content handler
        Parameters:
        delegate - The actual XML writer
        namespaces - The namespaces known to the Encoder
        numDecimals - How many decimals to preserve when writing ordinates
        forceDecimal - If xs:decimal compliant encoding should be used, or not
        gmlPrefix - The GML namespace prefix
      • GMLWriter

        public GMLWriter​(ContentHandler delegate,
                         NamespaceSupport namespaces,
                         int numDecimals,
                         boolean forceDecimal,
                         boolean padWithZeros,
                         String gmlPrefix)
        Create a new content handler
        Parameters:
        delegate - The actual XML writer
        namespaces - The namespaces known to the Encoder
        numDecimals - How many decimals to preserve when writing ordinates
        forceDecimal - If xs:decimal compliant encoding should be used, or not
        padWithZeros - If apply zero padding
        gmlPrefix - The GML namespace prefix
      • GMLWriter

        public GMLWriter​(ContentHandler delegate,
                         NamespaceSupport namespaces,
                         int numDecimals,
                         boolean forceDecimal,
                         boolean padWithZeros,
                         String gmlPrefix,
                         boolean encodeMeasures)
        Create a new content handler
        Parameters:
        delegate - The actual XML writer
        namespaces - The namespaces known to the Encoder
        numDecimals - How many decimals to preserve when writing ordinates
        forceDecimal - If xs:decimal compliant encoding should be used, or not
        gmlPrefix - The GML namespace prefix
        encodeMeasures - TRUE if coordinates measures should be included
    • Method Detail

      • setDocumentLocator

        public void setDocumentLocator​(Locator locator)
        See Also:
        ContentHandler.setDocumentLocator(org.xml.sax.Locator)
      • startDocument

        public void startDocument()
                           throws SAXException
        Throws:
        SAXException
        See Also:
        ContentHandler.startDocument()
      • endDocument

        public void endDocument()
                         throws SAXException
        Throws:
        SAXException
        See Also:
        ContentHandler.endDocument()
      • startPrefixMapping

        public void startPrefixMapping​(String prefix,
                                       String uri)
                                throws SAXException
        Throws:
        SAXException
        See Also:
        ContentHandler.startPrefixMapping(java.lang.String, java.lang.String)
      • endPrefixMapping

        public void endPrefixMapping​(String prefix)
                              throws SAXException
        Throws:
        SAXException
        See Also:
        ContentHandler.endPrefixMapping(java.lang.String)
      • startElement

        public void startElement​(QualifiedName qn,
                                 Attributes atts)
                          throws SAXException
        Throws:
        SAXException
        See Also:
        ContentHandler.startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
      • endElement

        public void endElement​(QualifiedName qn)
                        throws SAXException
        Throws:
        SAXException
        See Also:
        ContentHandler.endElement(java.lang.String, java.lang.String, java.lang.String)
      • coordinates

        public void coordinates​(CoordinateSequence cs)
                         throws SAXException
        Writes a GML2 coordinates element
        Throws:
        SAXException
      • position

        public void position​(double x,
                             double y,
                             double z)
                      throws SAXException
        Writes a single x/y position, without wrapping it in any element
        Throws:
        SAXException
      • position

        public void position​(CoordinateSequence coordinates)
                      throws SAXException
        Encodes the provided coordinates sequence, if encoding of measures is enabled this method will encode all the available ordinates.
        Parameters:
        coordinates - the coordinates sequence
        Throws:
        SAXException
      • ordinate

        public void ordinate​(double x)
                      throws SAXException
        Writes a single ordinate, without wrapping it inside any element
        Throws:
        SAXException
      • posList

        public void posList​(CoordinateSequence coordinateSequence)
                     throws SAXException
        Write a GML3 posList
        Throws:
        SAXException