Changeset 33652 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2017-09-22T03:50:33+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileVEC.java
r33650 r33652 11 11 12 12 import org.openstreetmap.josm.data.coor.EastNorth; 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.data.osm.BBox; 13 15 import org.openstreetmap.josm.data.osm.DataSet; 14 16 import org.openstreetmap.josm.data.osm.Node; 17 import org.openstreetmap.josm.data.osm.Way; 15 18 import org.openstreetmap.josm.data.projection.Projection; 16 19 import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileSCD.McdObjectDef; … … 161 164 /** TYP */ ArcType arcType; 162 165 /** PTC */ int nPoints; 163 /** COR */ EastNorth initialPoint; 164 /** COR */ EastNorth finalPoint; 166 /** COR */ final List<EastNorth> points = new ArrayList<>(); 165 167 /** ATC */ int nAttributes; 166 168 /** QAC */ int nQualities; … … 177 179 case "TYP": arcType = ArcType.of(safeGetInt(r)); break; 178 180 case "PTC": nPoints = safeGetInt(r); break; 179 case "COR": 180 EastNorth en = safeGetEastNorth(r); 181 if (initialPoint == null) { 182 initialPoint = en; 183 } else if (finalPoint == null) { 184 finalPoint = en; 185 } 186 break; 181 case "COR": points.add(safeGetEastNorth(r)); break; 187 182 case "ATC": nAttributes = safeGetInt(r); break; 188 183 case "QAC": nQualities = safeGetInt(r); break; … … 320 315 } 321 316 317 private static BBox around(LatLon ll) { 318 final double r = 1e-7; 319 return new BBox(ll.getX() - r, ll.getY() - r, ll.getX() + r, ll.getY() + r); 320 } 321 322 private static Node getNodeAt(DataSet ds, Projection proj, EastNorth en) { 323 LatLon ll = proj.eastNorth2latlon(en); 324 List<Node> nodes = ds.searchNodes(around(ll)); 325 if (nodes.isEmpty()) { 326 Node n = new Node(ll); 327 ds.addPrimitive(n); 328 return n; 329 } 330 return nodes.get(0); 331 } 332 322 333 @Override 323 334 public EdigeoFileVEC read(DataSet ds) throws IOException, ReflectiveOperationException { 324 335 super.read(ds); 325 336 Projection proj = lot.geo.getCoorReference().getProjection(); 337 // Nodes 326 338 for (NodeBlock nb : getNodes()) { 327 assert nb.getNumberOfAttributes() == 0; 328 assert nb.getNumberOfQualityIndicators() == 0; 329 lot.geo.toString(); 330 Node n = new Node(proj.eastNorth2latlon(nb.getCoordinate())); 331 ds.addPrimitive(n); 339 assert nb.nAttributes == 0 : nb; 340 assert nb.nQualities == 0 : nb; 341 LatLon ll = proj.eastNorth2latlon(nb.getCoordinate()); 342 if (ds.searchNodes(around(ll)).isEmpty()) { 343 ds.addPrimitive(new Node(ll)); 344 } 345 } 346 // Arcs 347 for (ArcBlock ab : getArcs()) { 348 assert ab.nAttributes == 0 : ab; 349 assert ab.nQualities == 0 : ab; 350 assert ab.nPoints >= 2 : ab; 351 Way w = new Way(); 352 for (EastNorth en : ab.points) { 353 w.addNode(getNodeAt(ds, proj, en)); 354 } 355 ds.addPrimitive(w); 332 356 } 333 357 return this;
Note:
See TracChangeset
for help on using the changeset viewer.