Changeset 34191 in osm for applications/editors/josm/plugins
- Timestamp:
- 2018-05-13T15:06:26+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/NeptuneReader.java
r33518 r34191 37 37 import org.xml.sax.SAXException; 38 38 39 import neptune.ChouetteAreaType;40 39 import neptune.ChouettePTNetworkType; 41 40 import neptune.ChouettePTNetworkType.ChouetteArea.AreaCentroid; … … 256 255 // Parsing Stop areas 257 256 for (StopArea sa : root.getChouetteArea().getStopArea()) { 258 if (sa.getStopAreaExtension().getAreaType().equals(ChouetteAreaType.COMMERCIAL_STOP_POINT)) { 259 Relation stopArea = createStopArea(sa); 260 stopArea.put("name", sa.getName()); 261 for (String childId : sa.getContains()) { 262 if (childId.contains("StopArea")) { 263 StopArea child = findStopArea(childId); 264 if (child == null) { 265 Logging.warn("Cannot find StopArea: "+childId); 266 } else { 267 if (child.getStopAreaExtension().getAreaType().equals(ChouetteAreaType.BOARDING_POSITION)) { 268 for (String grandchildId : child.getContains()) { 269 if (grandchildId.contains("StopPoint")) { 270 StopPoint grandchild = findStopPoint(grandchildId); 271 if (grandchild == null) { 272 Logging.warn("Cannot find StopPoint: "+grandchildId); 273 } else { 274 if (grandchild.getLongLatType().equals(LongLatTypeType.WGS_84)) { 275 Node platform = createPlatform(grandchild); 276 stopArea.addMember(new RelationMember(OSM_PLATFORM, platform)); 277 } else { 278 Logging.warn("Unsupported long/lat type: "+grandchild.getLongLatType()); 279 } 280 } 281 } else { 282 Logging.warn("Unsupported grandchild: "+grandchildId); 283 } 284 } 285 String centroidId = child.getCentroidOfArea(); 286 AreaCentroid areaCentroid = findAreaCentroid(centroidId); 287 if (areaCentroid == null) { 288 Logging.warn("Cannot find AreaCentroid: "+centroidId); 289 } else if (!areaCentroid.getLongLatType().equals(LongLatTypeType.WGS_84)) { 290 Logging.warn("Unsupported long/lat type: "+areaCentroid.getLongLatType()); 291 } else { 292 for (RelationMember member : stopArea.getMembers()) { 293 // Fix stop coordinates if needed 294 if (member.getRole().equals(OSM_PLATFORM) && isNullLatLon(member.getNode().getCoor())) { 295 member.getNode().setCoor(createLatLon(areaCentroid)); 296 } 297 } 298 } 299 } else { 300 Logging.warn("Unsupported child type: "+child.getStopAreaExtension().getAreaType()); 301 } 302 } 303 304 } else if (childId.contains("StopPoint")) { 305 StopPoint child = findStopPoint(childId); 306 if (child == null) { 307 Logging.warn("Cannot find StopPoint: "+childId); 308 } else { 309 // TODO 310 Logging.info("TODO: handle StopPoint "+childId); 311 } 312 313 } else { 314 Logging.warn("Unsupported child: "+childId); 315 } 316 } 317 } else if (sa.getStopAreaExtension().getAreaType().equals(ChouetteAreaType.BOARDING_POSITION)) { 318 //Main.info("skipping StopArea with type "+sa.getStopAreaExtension().getAreaType()+": "+sa.getObjectId()); 319 } else { 320 Logging.warn("Unsupported StopArea type: "+sa.getStopAreaExtension().getAreaType()); 257 switch (sa.getStopAreaExtension().getAreaType()) { 258 case COMMERCIAL_STOP_POINT: 259 case QUAY: 260 parseStopArea(sa); 261 break; 262 case BOARDING_POSITION: 263 //Main.info("skipping StopArea with type "+sa.getStopAreaExtension().getAreaType()+": "+sa.getObjectId()); 264 break; 265 default: 266 Logging.warn("Unsupported StopArea type: "+sa.getStopAreaExtension().getAreaType()); 321 267 } 322 268 } … … 355 301 } 356 302 303 private void parseStopArea(StopArea sa) { 304 Relation stopArea = createStopArea(sa); 305 stopArea.put("name", sa.getName()); 306 for (String childId : sa.getContains()) { 307 if (childId.contains("StopArea")) { 308 StopArea child = findStopArea(childId); 309 if (child == null) { 310 Logging.warn("Cannot find StopArea: "+childId); 311 } else { 312 switch (child.getStopAreaExtension().getAreaType()) { 313 case BOARDING_POSITION: 314 case QUAY: 315 parseStopAreaChild(stopArea, child); 316 break; 317 default: 318 Logging.warn("Unsupported child type: "+child.getStopAreaExtension().getAreaType()); 319 } 320 } 321 322 } else if (childId.contains("StopPoint")) { 323 StopPoint child = findStopPoint(childId); 324 if (child == null) { 325 Logging.warn("Cannot find StopPoint: "+childId); 326 } else { 327 // TODO 328 Logging.info("TODO: handle StopPoint "+childId); 329 } 330 331 } else { 332 Logging.warn("Unsupported child: "+childId); 333 } 334 } 335 } 336 337 private void parseStopAreaChild(Relation stopArea, StopArea child) { 338 for (String grandchildId : child.getContains()) { 339 if (grandchildId.contains("StopPoint")) { 340 StopPoint grandchild = findStopPoint(grandchildId); 341 if (grandchild == null) { 342 Logging.warn("Cannot find StopPoint: "+grandchildId); 343 } else { 344 if (grandchild.getLongLatType().equals(LongLatTypeType.WGS_84)) { 345 Node platform = createPlatform(grandchild); 346 stopArea.addMember(new RelationMember(OSM_PLATFORM, platform)); 347 } else { 348 Logging.warn("Unsupported long/lat type: "+grandchild.getLongLatType()); 349 } 350 } 351 } else { 352 Logging.warn("Unsupported grandchild: "+grandchildId); 353 } 354 } 355 String centroidId = child.getCentroidOfArea(); 356 AreaCentroid areaCentroid = findAreaCentroid(centroidId); 357 if (areaCentroid == null) { 358 Logging.warn("Cannot find AreaCentroid: "+centroidId); 359 } else if (!areaCentroid.getLongLatType().equals(LongLatTypeType.WGS_84)) { 360 Logging.warn("Unsupported long/lat type: "+areaCentroid.getLongLatType()); 361 } else { 362 for (RelationMember member : stopArea.getMembers()) { 363 // Fix stop coordinates if needed 364 if (member.getRole().equals(OSM_PLATFORM) && isNullLatLon(member.getNode().getCoor())) { 365 member.getNode().setCoor(createLatLon(areaCentroid)); 366 } 367 } 368 } 369 } 370 357 371 private static boolean addStopToRoute(Relation route, OsmPrimitive stop) { 358 372 if (route.getMembersCount() == 0 || !route.getMember(route.getMembersCount()-1).getMember().equals(stop)) {
Note:
See TracChangeset
for help on using the changeset viewer.