encodeNullBounds(); String boxName = boxName(); start(boxName); } else { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "srsName", "srsName", "", srsName); start(boxName, atts); end(boxName);
/** * writes null bounds to the output * * @throws RuntimeException if it is thorwn while writing the element * or coordinates */ public void writeNullBounds() { try { String boundedBy = geometryTranslator.getDefaultPrefix() + ":boundedBy"; String nullBox = geometryTranslator.getDefaultPrefix() + ":null"; contentHandler.startElement("", "", boundedBy, NULL_ATTS); contentHandler.startElement("", "", nullBox, NULL_ATTS); contentHandler.characters("unknown".toCharArray(), 0, "unknown".length()); contentHandler.endElement("", "", nullBox); contentHandler.endElement("", "", boundedBy); } catch (SAXException se) { throw new RuntimeException(se); } }
start(geomName); } else { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "srsName", "srsName", "", srsName); start(geomName, atts); writePolygon((Polygon) geometry); case GMLUtils.MULTIPOLYGON: case GMLUtils.MULTIGEOMETRY: writeMulti((GeometryCollection) geometry, GMLUtils.getMemberName(geometryType)); end(geomName);
geometryTranslator.encode((Geometry) value, srsName); } else if(value instanceof Date) { String text = null;
geometryTranslator.encode((Geometry) value, srsName); } else if(value instanceof Date) { String text = null;
start(geomName); } else { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "srsName", "srsName", "", srsName); start(geomName, atts); writePolygon((Polygon) geometry); case GMLUtils.MULTIPOLYGON: case GMLUtils.MULTIGEOMETRY: writeMulti((GeometryCollection) geometry, GMLUtils.getMemberName(geometryType)); end(geomName);
start(geomName); } else { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "srsName", "srsName", "", srsName); start(geomName, atts); writePolygon((Polygon) geometry); case GMLUtils.MULTIPOLYGON: case GMLUtils.MULTIGEOMETRY: writeMulti((GeometryCollection) geometry, GMLUtils.getMemberName(geometryType)); end(geomName);
encodeNullBounds(); String boxName = boxName(); start(boxName); } else { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "srsName", "srsName", "", srsName); start(boxName, atts); end(boxName);
encodeNullBounds(); String boxName = boxName(); start(boxName); } else { AttributesImpl atts = new AttributesImpl(); atts.addAttribute("", "srsName", "srsName", "", srsName); start(boxName, atts); end(boxName);
/** * writes the <code>gml:boundedBy</code> element to output based on * <code>fc.getBounds()</code> * * @param bounds * * @throws RuntimeException if it is thorwn while writing the element * or coordinates */ public void writeBounds(BoundingBox bounds) { try { String boundedBy = geometryTranslator.getDefaultPrefix() + ":" + "boundedBy"; contentHandler.startElement("", "", boundedBy, NULL_ATTS); Envelope env = null; if (bounds != null){ env = new Envelope(new Coordinate(bounds.getMinX(), bounds.getMinY()),new Coordinate(bounds.getMaxX(), bounds.getMaxY())); } geometryTranslator.encode(env, srsName); contentHandler.endElement("", "", boundedBy); } catch (SAXException se) { throw new RuntimeException(se); } }
/** * Encodes the given geometry with no srsName attribute and forcing 2D */ public void encode(Geometry geometry) { String srsName = null; // see if we have a EPSG CRS attached to the geometry if(geometry.getUserData() instanceof CoordinateReferenceSystem) { try { CoordinateReferenceSystem crs = (CoordinateReferenceSystem) geometry.getUserData(); Integer code = CRS.lookupEpsgCode(crs, false); if(code != null) { if(AxisOrder.NORTH_EAST.equals(CRS.getAxisOrder(crs))) { srsName = "urn:ogc:def:crs:EPSG::" + code; } else { srsName = "EPSG:" + code; } } } catch(Exception e) { LOGGER.fine("Failed to encode the CoordinateReferenceSystem into a srsName"); } } encode(geometry, srsName); }
/** * Constructor with handler. * * @param handler the handler to use. * @param prefix DOCUMENT ME! * @param ns DOCUMENT ME! * @param types DOCUMENT ME! * @param schemaLoc DOCUMENT ME! */ public FeatureTranslator(ContentHandler handler, String prefix, String ns, FeatureTypeNamespaces types, SchemaLocationSupport schemaLoc) { super(handler, prefix, ns, schemaLoc); geometryTranslator = createGeometryTranslator( handler ); this.types = types; this.handler = handler; getNamespaceSupport().declarePrefix(geometryTranslator .getDefaultPrefix(), geometryTranslator.getDefaultNamespace()); memberString = geometryTranslator.getDefaultPrefix() + ":featureMember"; }
/** * writes the <code>gml:boundedBy</code> element to output based on * <code>fc.getBounds()</code> * * @param bounds * * @throws RuntimeException if it is thorwn while writing the element * or coordinates */ public void writeBounds(Envelope bounds) { try { String boundedBy = geometryTranslator.getDefaultPrefix() + ":" + "boundedBy"; contentHandler.startElement("", "", boundedBy, NULL_ATTS); geometryTranslator.encode(bounds, srsName); contentHandler.endElement("", "", boundedBy); } catch (SAXException se) { throw new RuntimeException(se); } }
/** * Constructor with handler. * * @param handler the handler to use. * @param prefix prefix * @param ns namespace * @param types Capture namespace and prefix information for types * @param schemaLoc Schema location information */ public FeatureTranslator(ContentHandler handler, String prefix, String ns, FeatureTypeNamespaces types, SchemaLocationSupport schemaLoc) { super(handler, prefix, ns, schemaLoc); geometryTranslator = createGeometryTranslator( handler ); this.types = types; this.handler = handler; getNamespaceSupport().declarePrefix(geometryTranslator .getDefaultPrefix(), geometryTranslator.getDefaultNamespace()); memberString = geometryTranslator.getDefaultPrefix() + ":featureMember"; }
public Object visit(Literal expression, Object extraData) { Object value = expression.getValue(); if( value == null ){ element("Literal", ""); } else if (value instanceof Geometry) { geometryEncoder.encode( (Geometry) value ); } else { String txt = expression.evaluate(null, String.class ); if( txt == null ){ txt = value.toString(); } element("Literal",txt); } return extraData; }
/** * Method to be subclasses in order to allow for gml3 encoding for null enevelope. */ protected void encodeNullBounds() { start("null"); String text = "unknown"; try{ contentHandler.characters(text.toCharArray(), 0, text.length()); } catch(Exception e) //this shouldnt happen!! { System.out.println("got exception while writing null boundedby:"+e.getLocalizedMessage()); e.printStackTrace(); } end("null"); }
/** * Set up a GeometryTranslator for working with content of the indicate * dimension. * <p> * This method can be used by code explicitly wishing to output 2D ordinates. * * @since 2.4.1 * @param handler * @param numDecimals * @param dimension * @return GeometryTranslator that will delegate a CoordinateWriter configured with the above parameters */ protected GeometryTranslator createGeometryTranslator( ContentHandler handler, int numDecimals, int dimension ) { return new GeometryTranslator( handler, "gml",GMLUtils.GML_URL, numDecimals, false, dimension); }
public void encode(Object o) throws IllegalArgumentException { encode(o, null); }