public int getSRID() { return polygon.getSRID(); }
public Object parse(Handler arg, GeometryFactory gf) throws SAXException { // one child, either a coord // or a coordinate sequence if(arg.children.size()<1) throw new SAXException("Cannot create a polygon without atleast one linear ring"); int srid = getSrid(arg.attrs,gf.getSRID()); LinearRing outer = (LinearRing) arg.children.get(0); // will be the first List t = arg.children.size()>1?arg.children.subList(1,arg.children.size()):null; LinearRing[] inner = t==null?null:(LinearRing[]) t.toArray(new LinearRing[t.size()]); Polygon p = gf.createPolygon(outer,inner); if(p.getSRID()!=srid) p.setSRID(srid); return p; } });
/** * Creates the polygon. * * @param wkt * the wkt * @return the polygon * @throws ParseException * the parse exception */ public Polygon createPolygon(String wkt) throws ParseException { Polygon poly = polAdapter.unmarshal(wkt); if (poly.getSRID() == 0) { poly.setSRID(4326); } return poly; }
@Override public String marshal(Polygon the_geom) throws ParseException { if (the_geom != null) { WKTWriter wktWriter = new WKTWriter(); if (the_geom.getSRID() == 0) the_geom.setSRID(4326); return wktWriter.write(the_geom); } else { throw new ParseException("Polygon obj is null."); } } }
@Override public String marshal(Polygon the_geom) throws ParseException { if (the_geom != null) { WKTWriter wktWriter = new WKTWriter(); if (the_geom.getSRID() == 0) the_geom.setSRID(4326); return wktWriter.write(the_geom); } else { throw new ParseException("Polygon obj is null."); } } }
@Override public String marshal(Polygon the_geom) throws ParseException { if (the_geom != null) { WKTWriter wktWriter = new WKTWriter(); if (the_geom.getSRID() == 0) the_geom.setSRID(4326); return wktWriter.write(the_geom); } else { throw new ParseException("Polygon obj is null."); } } }
@Override public String marshal(Polygon the_geom) throws ParseException { if (the_geom != null) { WKTWriter wktWriter = new WKTWriter(); if (the_geom.getSRID() == 0) the_geom.setSRID(4326); return wktWriter.write(the_geom); } else { throw new ParseException("Polygon obj is null."); } } }
@Override public MultiPolygon apply(Polygon object) throws UnconvertibleObjectException { final MultiPolygon geom = object.getFactory().createMultiPolygon(new Polygon[]{object}); geom.setSRID(object.getSRID()); geom.setUserData(object.getUserData()); return geom; }