Changeset 35110 in osm for applications/editors/josm/plugins
- Timestamp:
- 2019-09-11T14:10:24+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/jrenderpgsql/src/jrenderpgsql/JrenderPgsql.java
r35094 r35110 34 34 import org.postgis.LineString; 35 35 import org.postgis.Polygon; 36 import org.postgis.MultiPolygon; 36 37 import org.postgis.LinearRing; 37 38 import org.postgis.PGgeometry; … … 109 110 } 110 111 112 private static void addpoly(Polygon po, String table, String osmid) 113 { 114 if (po.numRings() > 1) 115 { 116 System.err.println("warning: polygons with holes not supported (" + table + " id=" + osmid + ")"); 117 } 118 LinearRing lr = (LinearRing) po.getRing(0); 119 waybuf.append("<way id=\""); 120 waybuf.append(++wid); 121 waybuf.append("\" version=\"1\" user=\"1\" uid=\"1\" changeset=\"1\" timestamp=\"1980-01-01T00:00:00Z\">\n"); 122 for (int i=0; i < lr.numPoints(); i++) 123 { 124 int n = addnode ((Point) lr.getPoint(i), true); 125 waybuf.append("<nd ref=\"" + n + "\" />\n"); 126 } 127 } 128 111 129 /** 112 130 * helper for adding a PostGIS geometry to pseudo OSM XML 113 131 * @returns either the node or the way string buffer, depending on geom type 114 132 */ 115 private static StringBuilder decode_geom(PGgeometry geom )133 private static StringBuilder decode_geom(PGgeometry geom, String table, String osmid) 116 134 { 117 135 if (geom.getGeoType() == Geometry.POINT) … … 135 153 else if (geom.getGeoType() == Geometry.POLYGON) 136 154 { 137 Polygon po = (Polygon) geom.getGeometry(); 138 if (po.numRings() > 1) 139 { 140 System.err.println("warning: polygons with holes not supported"); 141 } 142 LinearRing lr = (LinearRing) po.getRing(0); 143 waybuf.append("<way id=\""); 144 waybuf.append(++wid); 145 waybuf.append("\" version=\"1\" user=\"1\" uid=\"1\" changeset=\"1\" timestamp=\"1980-01-01T00:00:00Z\">\n"); 146 for (int i=0; i < lr.numPoints(); i++) 147 { 148 int n = addnode ((Point) lr.getPoint(i), true); 149 waybuf.append("<nd ref=\"" + n + "\" />\n"); 155 addpoly((Polygon) geom.getGeometry(), table, osmid); 156 return waybuf; 157 } 158 else if (geom.getGeoType() == Geometry.MULTIPOLYGON) 159 { 160 MultiPolygon po = (MultiPolygon) geom.getGeometry(); 161 for (Polygon p : po.getPolygons()) 162 { 163 addpoly(p, table, osmid); 150 164 } 151 165 return waybuf; … … 299 313 int geomcol = 0; 300 314 int tagscol = 0; 315 int idcol = 0; 301 316 for (int i = 1; i<colCount; i++) 302 317 { … … 306 321 } else if (n.equals("tags")) { 307 322 tagscol = i; 323 } else if (n.equals("osm_id")) { 324 idcol = i; 308 325 } else if (n.equals("mygeom")) { 309 326 geomcol = i; … … 330 347 { 331 348 PGgeometry geom = (PGgeometry) rs.getObject(geomcol); 332 StringBuilder currentbuf = decode_geom(geom); 349 String osmid = (idcol> 0) ? rs.getString(idcol) : "nil"; 350 StringBuilder currentbuf = decode_geom(geom, table, osmid); 333 351 334 352 for (int i = 1; i<colCount; i++)
Note:
See TracChangeset
for help on using the changeset viewer.