MultiPolygon multiPolygon = geometryFactory.createMultiPolygon(polygonArray); multiPolygon.setUserData(getSRS()); multiPolygon.setSRID(getSRID()); LOGGER.fine("created " + multiPolygon);
polys.setSRID(SRID);
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 multi-polygon without atleast one polygon"); int srid = getSrid(arg.attrs,gf.getSRID()); Polygon[] plys = (Polygon[]) arg.children.toArray(new Polygon[arg.children.size()]); MultiPolygon mp = gf.createMultiPolygon(plys); if(mp.getSRID()!=srid) mp.setSRID(srid); return mp; } });
/** * Creates the multi polygon. * * @param pol * the pol * @return the multi polygon */ public MultiPolygon createMultiPolygon(Polygon[] pol) { MultiPolygon multiPoly = this.factory.createMultiPolygon(pol); if (multiPoly.getSRID() == 0) { multiPoly.setSRID(4326); } return multiPoly; }
/** * Creates the multi polygon. * * @param wkt * the wkt * @return the multi polygon * @throws ParseException * the parse exception */ public MultiPolygon createMultiPolygon(String wkt) throws ParseException { MultiPolygon multiPoly = this.multiPolAdapter.unmarshal(wkt); if (multiPoly.getSRID() == 0) { multiPoly.setSRID(4326); } return multiPoly; }
/** * Creates the wkt from multi polygon. * * @param multiPoly * the multi poly * @return the string * @throws ParseException * the parse exception */ public String createWKTFromMultiPolygon(MultiPolygon multiPoly) throws ParseException { if (multiPoly.getSRID() == 0) { multiPoly.setSRID(4326); } return this.multiPolAdapter.marshal(multiPoly); } }
private MultiPolygon parseAllowedArea(String allowedArea) { if (allowedArea == null || allowedArea.isEmpty()) { return null; } String[] allowedAreaParts = allowedArea.split(";"); if (allowedAreaParts.length != 2) { throw new GeoServerRuntimException( String.format( "Invalid allowed area '%s' expecting SRID=<CODE>;<WKT>.", allowedArea)); } Integer srid; Geometry geometry; try { srid = Integer.valueOf(allowedAreaParts[0].split("=")[1]); geometry = new WKTReader().read(allowedAreaParts[1]); } catch (Exception exception) { String message = String.format( "Error parsing SRID '%s' or WKT geometry '%s' expecting SRID=<CODE>;<WKT>.", allowedAreaParts[0], allowedAreaParts[1]); LOGGER.log(Level.WARNING, message, exception); throw new GeoServerRuntimException(message, exception); } MultiPolygon multiPolygon = castToMultiPolygon(geometry); multiPolygon.setSRID(srid); return multiPolygon; }
@Override public String marshal(MultiPolygon 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("Geometry obj is null."); } } }
@Override public String marshal(MultiPolygon 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("Geometry obj is null."); } } }
@Override public String marshal(MultiPolygon 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("Geometry obj is null."); } } }
@Override public String marshal(MultiPolygon 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("Geometry 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; }
public RuleLimits toRuleLimits(RuleLimits ruleLimits) { if (ruleLimits == null) { ruleLimits = new RuleLimits(); } if (getAllowedArea() != null) { try { String areaWKT = getAllowedArea(); int areaSRID = -1; if (getAllowedArea().startsWith("SRID")) { areaWKT = getAllowedArea().split(";")[1]; areaSRID = Integer.parseInt(getAllowedArea().split(";")[0].split("=")[1]); } MultiPolygon area = (MultiPolygon) new WKTReader().read(areaWKT); area.setSRID(areaSRID); ruleLimits.setAllowedArea(area); } catch (ParseException e) { ruleLimits.setAllowedArea(null); } } if (getCatalogMode() != null) { ruleLimits.setCatalogMode(CatalogMode.valueOf(getCatalogMode().toUpperCase())); } return ruleLimits; } }
public RuleLimits toRuleLimits(RuleLimits ruleLimits) { if (ruleLimits == null) { ruleLimits = new RuleLimits(); } if (getAllowedArea() != null) { try { String areaWKT = getAllowedArea(); int areaSRID = -1; if (getAllowedArea().startsWith("SRID")) { areaWKT = getAllowedArea().split(";")[1]; areaSRID = Integer.parseInt(getAllowedArea().split(";")[0].split("=")[1]); } MultiPolygon area = (MultiPolygon) new WKTReader().read(areaWKT); area.setSRID(areaSRID); ruleLimits.setAllowedArea(area); } catch (ParseException e) { ruleLimits.setAllowedArea(null); } } if (getCatalogMode() != null) { ruleLimits.setCatalogMode(CatalogMode.valueOf(getCatalogMode().toUpperCase())); } return ruleLimits; } }
area.setSRID(areaSRID); details.setArea(area); } catch (ParseException e) {
area.setSRID(areaSRID); details.setArea(area); } catch (ParseException e) {