Changeset 30731 in osm for applications/editors/josm/plugins/opendata/modules/fr.paris/src
- Timestamp:
- 2014-10-18T15:31:53+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris
- Files:
-
- 12 edited
-
ParisConstants.java (modified) (1 diff)
-
ParisLicense.java (modified) (1 diff)
-
ParisModule.java (modified) (1 diff)
-
datasets/ParisDataSetHandler.java (modified) (1 diff)
-
datasets/ParisShpHandler.java (modified) (1 diff)
-
datasets/deplacements/ElectriciteHandler.java (modified) (1 diff)
-
datasets/environnement/ArbresRemarquablesHandler.java (modified) (1 diff)
-
datasets/environnement/MobilierVoiePubliqueHandler.java (modified) (1 diff)
-
datasets/urbanisme/EclairagePublicHandler.java (modified) (1 diff)
-
datasets/urbanisme/SanisettesHandler.java (modified) (1 diff)
-
datasets/urbanisme/VolumesBatisHandler.java (modified) (1 diff)
-
datasets/urbanisme/VolumesNonBatisHandler.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/ParisConstants.java
r30563 r30731 4 4 5 5 public interface ParisConstants { 6 7 /**8 * Source9 */10 public static final String SOURCE = "opendataparis";11 12 /**13 * Portal14 */15 public static final String PORTAL = "http://opendata.paris.fr/opendata/";6 7 /** 8 * Source 9 */ 10 public static final String SOURCE = "opendataparis"; 11 12 /** 13 * Portal 14 */ 15 public static final String PORTAL = "http://opendata.paris.fr/opendata/"; 16 16 17 /**18 * Icons19 */20 public static final String ICON_PARIS_24 = "data.fr.paris_24.png";17 /** 18 * Icons 19 */ 20 public static final String ICON_PARIS_24 = "data.fr.paris_24.png"; 21 21 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/ParisLicense.java
r30340 r30731 6 6 public class ParisLicense extends ODbL { 7 7 8 public ParisLicense() {9 // TODO: Paris license10 /*try {11 setURL(PORTAL + "/la-licence", "fr");12 } catch (MalformedURLException e) {13 e.printStackTrace();14 }*/15 }8 public ParisLicense() { 9 // TODO: Paris license 10 /*try { 11 setURL(PORTAL + "/la-licence", "fr"); 12 } catch (MalformedURLException e) { 13 e.printStackTrace(); 14 }*/ 15 } 16 16 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/ParisModule.java
r30340 r30731 11 11 public class ParisModule extends AbstractModule { 12 12 13 public ParisModule(ModuleInformation info) {14 super(info);13 public ParisModule(ModuleInformation info) { 14 super(info); 15 15 handlers.add(SanisettesHandler.class); 16 16 handlers.add(ArbresRemarquablesHandler.class); -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/ParisDataSetHandler.java
r30340 r30731 11 11 12 12 public abstract class ParisDataSetHandler extends FrenchDataSetHandler implements ParisConstants { 13 14 private int documentId;15 private static final int portletId = 106; // FIXME16 17 public ParisDataSetHandler(int documentId) {18 init(documentId);19 }20 21 public ParisDataSetHandler(int documentId, String relevantTag) {22 super(relevantTag);23 init(documentId);24 }25 26 public ParisDataSetHandler(int documentId, boolean relevantUnion, String ... relevantTags) {27 super(relevantUnion, relevantTags);28 init(documentId);29 }13 14 private int documentId; 15 private static final int portletId = 106; // FIXME 16 17 public ParisDataSetHandler(int documentId) { 18 init(documentId); 19 } 20 21 public ParisDataSetHandler(int documentId, String relevantTag) { 22 super(relevantTag); 23 init(documentId); 24 } 25 26 public ParisDataSetHandler(int documentId, boolean relevantUnion, String ... relevantTags) { 27 super(relevantUnion, relevantTags); 28 init(documentId); 29 } 30 30 31 public ParisDataSetHandler(int documentId, String ... relevantTags) {32 this(documentId, false, relevantTags);33 }31 public ParisDataSetHandler(int documentId, String ... relevantTags) { 32 this(documentId, false, relevantTags); 33 } 34 34 35 public ParisDataSetHandler(int documentId, boolean relevantUnion, Tag ... relevantTags) {36 super(relevantUnion, relevantTags);37 init(documentId);38 }35 public ParisDataSetHandler(int documentId, boolean relevantUnion, Tag ... relevantTags) { 36 super(relevantUnion, relevantTags); 37 init(documentId); 38 } 39 39 40 private final void init(int documentId) {41 this.documentId = documentId;42 setLicense(new ParisLicense());43 try {44 if (documentId > 0) {45 setLocalPortalURL(PORTAL + "jsp/site/Portal.jsp?document_id="+documentId + "&portlet_id="+portletId);46 }47 } catch (MalformedURLException e) {48 e.printStackTrace();49 }50 }40 private final void init(int documentId) { 41 this.documentId = documentId; 42 setLicense(new ParisLicense()); 43 try { 44 if (documentId > 0) { 45 setLocalPortalURL(PORTAL + "jsp/site/Portal.jsp?document_id="+documentId + "&portlet_id="+portletId); 46 } 47 } catch (MalformedURLException e) { 48 e.printStackTrace(); 49 } 50 } 51 51 52 @Override53 public String getSource() {54 return SOURCE;55 }52 @Override 53 public String getSource() { 54 return SOURCE; 55 } 56 56 57 @Override58 public String getLocalPortalIconName() {59 return ICON_PARIS_24;60 }61 62 protected abstract String getDirectLink();57 @Override 58 public String getLocalPortalIconName() { 59 return ICON_PARIS_24; 60 } 61 62 protected abstract String getDirectLink(); 63 63 64 @Override65 public URL getDataURL() {66 try {67 if (documentId > 0) {68 return new URL(PORTAL + "rating/download/?id_resource="+documentId + "&type_resource=document&url="+getDirectLink());69 }70 } catch (MalformedURLException e) {71 e.printStackTrace();72 }73 return null;74 }64 @Override 65 public URL getDataURL() { 66 try { 67 if (documentId > 0) { 68 return new URL(PORTAL + "rating/download/?id_resource="+documentId + "&type_resource=document&url="+getDirectLink()); 69 } 70 } catch (MalformedURLException e) { 71 e.printStackTrace(); 72 } 73 return null; 74 } 75 75 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/ParisShpHandler.java
r30563 r30731 18 18 19 19 public class ParisShpHandler extends FrenchShpHandler { 20 21 public final Map<String, Node> nodeMap = new HashMap<>();22 23 protected OsmPrimitive dataPrimitive;24 protected Way closedWay;25 protected List<Way> ways;26 public List<Node> nodes;27 28 public ParisShpHandler() {29 setDbfCharset(Charset.forName(OdConstants.CP850));30 }31 32 private Node getNode(EastNorth en, String key) {33 Node n = nodeMap.get(key);34 /*if (n == null) {35 for (Node node : nodes.values()) {36 if (node.getEastNorth().equalsEpsilon(en, 0.0000001)) {37 return node;38 }39 }40 }*/41 return n;42 }43 44 protected Node createOrGetNode(DataSet ds, EastNorth en) {45 String key = en.getX()+"/"+en.getY();46 Node n = getNode(en, key);47 if (n == null) {48 n = new Node(en);49 nodeMap.put(key, n);50 ds.addPrimitive(n);51 }52 return n;53 }20 21 public final Map<String, Node> nodeMap = new HashMap<>(); 22 23 protected OsmPrimitive dataPrimitive; 24 protected Way closedWay; 25 protected List<Way> ways; 26 public List<Node> nodes; 27 28 public ParisShpHandler() { 29 setDbfCharset(Charset.forName(OdConstants.CP850)); 30 } 31 32 private Node getNode(EastNorth en, String key) { 33 Node n = nodeMap.get(key); 34 /*if (n == null) { 35 for (Node node : nodes.values()) { 36 if (node.getEastNorth().equalsEpsilon(en, 0.0000001)) { 37 return node; 38 } 39 } 40 }*/ 41 return n; 42 } 43 44 protected Node createOrGetNode(DataSet ds, EastNorth en) { 45 String key = en.getX()+"/"+en.getY(); 46 Node n = getNode(en, key); 47 if (n == null) { 48 n = new Node(en); 49 nodeMap.put(key, n); 50 ds.addPrimitive(n); 51 } 52 return n; 53 } 54 54 55 protected final void initFeaturesPrimitives(Set<OsmPrimitive> featurePrimitives) {56 dataPrimitive = null;57 closedWay = null;58 ways = new ArrayList<>();59 nodes = new ArrayList<>();60 for (OsmPrimitive p : featurePrimitives) {61 if (p.hasKeys()) {62 dataPrimitive = p;63 }64 if (p instanceof Way) {65 Way w = (Way) p;66 ways.add(w);67 if (w.isClosed()) {68 closedWay = w;69 }70 } else if (p instanceof Node) {71 nodes.add((Node) p);72 }73 }74 }75 76 protected final void removePrimitives(DataSet result) {77 for (Way w : ways) {78 w.setNodes(null);79 result.removePrimitive(w);80 }81 for (Node n : nodes) {82 result.removePrimitive(n);83 }84 }55 protected final void initFeaturesPrimitives(Set<OsmPrimitive> featurePrimitives) { 56 dataPrimitive = null; 57 closedWay = null; 58 ways = new ArrayList<>(); 59 nodes = new ArrayList<>(); 60 for (OsmPrimitive p : featurePrimitives) { 61 if (p.hasKeys()) { 62 dataPrimitive = p; 63 } 64 if (p instanceof Way) { 65 Way w = (Way) p; 66 ways.add(w); 67 if (w.isClosed()) { 68 closedWay = w; 69 } 70 } else if (p instanceof Node) { 71 nodes.add((Node) p); 72 } 73 } 74 } 75 76 protected final void removePrimitives(DataSet result) { 77 for (Way w : ways) { 78 w.setNodes(null); 79 result.removePrimitive(w); 80 } 81 for (Node n : nodes) { 82 result.removePrimitive(n); 83 } 84 } 85 85 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/deplacements/ElectriciteHandler.java
r30340 r30731 7 7 public class ElectriciteHandler extends ParisDataSetHandler { 8 8 9 public ElectriciteHandler() {10 super(95);11 setName("Électricité");12 }9 public ElectriciteHandler() { 10 super(95); 11 setName("Électricité"); 12 } 13 13 14 @Override15 public boolean acceptsFilename(String filename) {16 return acceptsShpFilename(filename, "electricite") || acceptsZipFilename(filename, "electricite");17 }18 19 @Override20 public void updateDataSet(DataSet ds) {21 // TODO22 }14 @Override 15 public boolean acceptsFilename(String filename) { 16 return acceptsShpFilename(filename, "electricite") || acceptsZipFilename(filename, "electricite"); 17 } 18 19 @Override 20 public void updateDataSet(DataSet ds) { 21 // TODO 22 } 23 23 24 @Override25 protected String getDirectLink() {26 return PORTAL+"hn/electricite.zip";27 }24 @Override 25 protected String getDirectLink() { 26 return PORTAL+"hn/electricite.zip"; 27 } 28 28 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/environnement/ArbresRemarquablesHandler.java
r30340 r30731 8 8 public class ArbresRemarquablesHandler extends ParisDataSetHandler { 9 9 10 public ArbresRemarquablesHandler() {11 super(107);12 setName("Arbres remarquables");13 }10 public ArbresRemarquablesHandler() { 11 super(107); 12 setName("Arbres remarquables"); 13 } 14 14 15 @Override16 public boolean acceptsFilename(String filename) {17 return acceptsShpFilename(filename, "arbres_remarquables") || acceptsZipFilename(filename, "arbres_remarquables_20..");18 }19 20 @Override21 public void updateDataSet(DataSet ds) {22 for (Node n : ds.getNodes()) {23 n.put("natural", "tree");24 replace(n, "ANNEE__PLA", "start_date");25 }26 }15 @Override 16 public boolean acceptsFilename(String filename) { 17 return acceptsShpFilename(filename, "arbres_remarquables") || acceptsZipFilename(filename, "arbres_remarquables_20.."); 18 } 19 20 @Override 21 public void updateDataSet(DataSet ds) { 22 for (Node n : ds.getNodes()) { 23 n.put("natural", "tree"); 24 replace(n, "ANNEE__PLA", "start_date"); 25 } 26 } 27 27 28 @Override29 protected String getDirectLink() {30 return PORTAL+"hn/arbres_remarquables_2011.zip";31 }28 @Override 29 protected String getDirectLink() { 30 return PORTAL+"hn/arbres_remarquables_2011.zip"; 31 } 32 32 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/environnement/MobilierVoiePubliqueHandler.java
r30340 r30731 14 14 public class MobilierVoiePubliqueHandler extends ParisDataSetHandler { 15 15 16 private final InternalShpHandler shpHandler = new InternalShpHandler();17 18 public MobilierVoiePubliqueHandler() {19 super(96);20 setName("Mobiliers sur voie publique");21 setShpHandler(shpHandler);22 }16 private final InternalShpHandler shpHandler = new InternalShpHandler(); 17 18 public MobilierVoiePubliqueHandler() { 19 super(96); 20 setName("Mobiliers sur voie publique"); 21 setShpHandler(shpHandler); 22 } 23 23 24 @Override25 public boolean acceptsFilename(String filename) {26 return acceptsShpFilename(filename, "environnement") || acceptsZipFilename(filename, "environnement");27 }24 @Override 25 public boolean acceptsFilename(String filename) { 26 return acceptsShpFilename(filename, "environnement") || acceptsZipFilename(filename, "environnement"); 27 } 28 28 29 @Override30 protected String getDirectLink() {31 return PORTAL+"hn/environnement.zip";32 }33 34 private final class InternalShpHandler extends ParisShpHandler {35 @Override36 public void notifyFeatureParsed(Object feature, DataSet result,Set<OsmPrimitive> featurePrimitives) {37 initFeaturesPrimitives(featurePrimitives);38 String type = dataPrimitive.get("Libelle");39 if (type.startsWith("Banc ")) {40 if (closedWay == null && dataPrimitive instanceof Way && ((Way)dataPrimitive).getNodesCount() > 3) {41 // Some benches can be converted to closed ways by removing some extra nodes at the beginning42 Way copy = new Way((Way) dataPrimitive);43 while (copy.getNodesCount() > 3 && !copy.isClosed()) {44 copy.removeNode(copy.getNode(0));45 }46 if (copy.isClosed()) {47 closedWay = copy;48 } else {49 // Try in the opposite direction (remove nodes from the end)50 copy = new Way((Way) dataPrimitive);51 while (copy.getNodesCount() > 3 && !copy.isClosed()) {52 copy.removeNode(copy.getNode(copy.getNodesCount()-1));53 }54 if (copy.isClosed()) {55 closedWay = copy;56 }57 }58 }59 if (closedWay != null) {60 Node bench = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes()));61 bench.put("amenity", "bench");62 bench.put("description", type);63 removePrimitives(result);64 } else {65 System.err.println("Bench without closed area: "+type);66 }67 } else if (type.startsWith("Poubelle") || type.startsWith("Borne de propreté")) {68 if (closedWay != null) {69 Node basket = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes()));70 basket.put("amenity", "waste_basket");71 basket.put("description", type);72 removePrimitives(result);73 } else {74 System.err.println("Waste basket without closed area: "+type);75 }76 } else if (type.startsWith("Bac à sable")) {77 if (closedWay == null && dataPrimitive instanceof Way && ((Way)dataPrimitive).getNodesCount() == 2) {78 // Sandpits are badly built, fix them79 closedWay = (Way) dataPrimitive;80 for (Way w : ways) {81 if (w.getNodesCount() == 4) {82 Node n1 = w.getNode(1);83 Node n2 = w.getNode(2);84 if (closedWay.getNode(1).getCoor().distance(n1.getCoor()) < closedWay.getNode(1).getCoor().distance(n2.getCoor())) {85 closedWay.addNode(n1);86 closedWay.addNode(n2);87 } else {88 closedWay.addNode(n2);89 closedWay.addNode(n1);90 }91 closedWay.addNode(closedWay.getNode(0));92 break;93 }94 }95 }96 if (closedWay != null) {97 // FIXME: lines commented as "sandpits" in this data set seem to be false data98 /*Node pg = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes()));99 pg.put("leisure", "playground");100 pg.put("playground", "sandpit");101 pg.put("description", type);*/102 removePrimitives(result);103 } else {104 System.err.println("Sandpit without closed area: "+type);105 }106 } else if (type.startsWith("Corbeille florale")) {107 if (closedWay != null) {108 Node n = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes()));109 n.put("man_made", "floral_basket");110 n.put("description", type);111 removePrimitives(result);112 } else {113 System.err.println("Floral basket without closed area: "+type);114 }115 } else if (type.startsWith("Objet sans identification particulière")) {116 //dataPrimitive.put("FIXME", "unknown object. DO NOT upload as it !");117 removePrimitives(result);118 } else {119 System.err.println("Unsupported object type: "+type);120 }121 }122 }123 124 @Override125 public void updateDataSet(DataSet ds) {126 // Done in notifyFeatureParsed() for drastic performance reasons127 shpHandler.nodes.clear();128 }29 @Override 30 protected String getDirectLink() { 31 return PORTAL+"hn/environnement.zip"; 32 } 33 34 private final class InternalShpHandler extends ParisShpHandler { 35 @Override 36 public void notifyFeatureParsed(Object feature, DataSet result, Set<OsmPrimitive> featurePrimitives) { 37 initFeaturesPrimitives(featurePrimitives); 38 String type = dataPrimitive.get("Libelle"); 39 if (type.startsWith("Banc ")) { 40 if (closedWay == null && dataPrimitive instanceof Way && ((Way)dataPrimitive).getNodesCount() > 3) { 41 // Some benches can be converted to closed ways by removing some extra nodes at the beginning 42 Way copy = new Way((Way) dataPrimitive); 43 while (copy.getNodesCount() > 3 && !copy.isClosed()) { 44 copy.removeNode(copy.getNode(0)); 45 } 46 if (copy.isClosed()) { 47 closedWay = copy; 48 } else { 49 // Try in the opposite direction (remove nodes from the end) 50 copy = new Way((Way) dataPrimitive); 51 while (copy.getNodesCount() > 3 && !copy.isClosed()) { 52 copy.removeNode(copy.getNode(copy.getNodesCount()-1)); 53 } 54 if (copy.isClosed()) { 55 closedWay = copy; 56 } 57 } 58 } 59 if (closedWay != null) { 60 Node bench = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes())); 61 bench.put("amenity", "bench"); 62 bench.put("description", type); 63 removePrimitives(result); 64 } else { 65 System.err.println("Bench without closed area: "+type); 66 } 67 } else if (type.startsWith("Poubelle") || type.startsWith("Borne de propreté")) { 68 if (closedWay != null) { 69 Node basket = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes())); 70 basket.put("amenity", "waste_basket"); 71 basket.put("description", type); 72 removePrimitives(result); 73 } else { 74 System.err.println("Waste basket without closed area: "+type); 75 } 76 } else if (type.startsWith("Bac à sable")) { 77 if (closedWay == null && dataPrimitive instanceof Way && ((Way)dataPrimitive).getNodesCount() == 2) { 78 // Sandpits are badly built, fix them 79 closedWay = (Way) dataPrimitive; 80 for (Way w : ways) { 81 if (w.getNodesCount() == 4) { 82 Node n1 = w.getNode(1); 83 Node n2 = w.getNode(2); 84 if (closedWay.getNode(1).getCoor().distance(n1.getCoor()) < closedWay.getNode(1).getCoor().distance(n2.getCoor())) { 85 closedWay.addNode(n1); 86 closedWay.addNode(n2); 87 } else { 88 closedWay.addNode(n2); 89 closedWay.addNode(n1); 90 } 91 closedWay.addNode(closedWay.getNode(0)); 92 break; 93 } 94 } 95 } 96 if (closedWay != null) { 97 // FIXME: lines commented as "sandpits" in this data set seem to be false data 98 /*Node pg = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes())); 99 pg.put("leisure", "playground"); 100 pg.put("playground", "sandpit"); 101 pg.put("description", type);*/ 102 removePrimitives(result); 103 } else { 104 System.err.println("Sandpit without closed area: "+type); 105 } 106 } else if (type.startsWith("Corbeille florale")) { 107 if (closedWay != null) { 108 Node n = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes())); 109 n.put("man_made", "floral_basket"); 110 n.put("description", type); 111 removePrimitives(result); 112 } else { 113 System.err.println("Floral basket without closed area: "+type); 114 } 115 } else if (type.startsWith("Objet sans identification particulière")) { 116 //dataPrimitive.put("FIXME", "unknown object. DO NOT upload as it !"); 117 removePrimitives(result); 118 } else { 119 System.err.println("Unsupported object type: "+type); 120 } 121 } 122 } 123 124 @Override 125 public void updateDataSet(DataSet ds) { 126 // Done in notifyFeatureParsed() for drastic performance reasons 127 shpHandler.nodes.clear(); 128 } 129 129 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/urbanisme/EclairagePublicHandler.java
r30340 r30731 13 13 public class EclairagePublicHandler extends ParisDataSetHandler { 14 14 15 private final InternalShpHandler shpHandler = new InternalShpHandler();16 17 public EclairagePublicHandler() {18 super(94);19 setName("Éclairage public");20 setShpHandler(shpHandler);21 }15 private final InternalShpHandler shpHandler = new InternalShpHandler(); 16 17 public EclairagePublicHandler() { 18 super(94); 19 setName("Éclairage public"); 20 setShpHandler(shpHandler); 21 } 22 22 23 @Override24 public boolean acceptsFilename(String filename) {25 return acceptsShpFilename(filename, "eclairage_public") || acceptsZipFilename(filename, "eclairage_public");26 }23 @Override 24 public boolean acceptsFilename(String filename) { 25 return acceptsShpFilename(filename, "eclairage_public") || acceptsZipFilename(filename, "eclairage_public"); 26 } 27 27 28 @Override29 protected String getDirectLink() {30 return PORTAL+"hn/eclairage_public.zip";31 }32 33 private final class InternalShpHandler extends ParisShpHandler {34 35 @Override36 public void notifyFeatureParsed(Object feature, DataSet result,Set<OsmPrimitive> featurePrimitives) {37 initFeaturesPrimitives(featurePrimitives);38 if (dataPrimitive == null) {39 System.err.println("Found no primitive with tags");40 } else if (closedWay == null) {41 // ;Objet sans identification particulière pour ce niveau et cette thématique;147;eclairage_public.zip;Niveau 1842 dataPrimitive.put("FIXME", "This way is not closed and has not been recognized as highway=street_lamp.");43 } else {44 Node centroid = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes()));45 if (!centroid.hasKeys()) {46 centroid.setKeys(dataPrimitive.getKeys());47 centroid.put("highway", "street_lamp");48 replace(centroid, "Libelle", "lamp_model:fr");49 } else if (centroid.get("lamp_model:fr") != null && (dataPrimitive.get("Libelle") == null || !dataPrimitive.get("Libelle").equals(centroid.get("lamp_model:fr")))) {50 System.err.println("Found 2 street lamps at the same position with different types: '"+centroid.get("lamp_model:fr")+"' and '"+dataPrimitive.get("Libelle")+"'.");51 }52 removePrimitives(result);53 54 if (centroid.get("lamp_model:fr") != null) {55 if (centroid.get("lamp_model:fr").contains("mural") && !centroid.get("lamp_model:fr").contains("au sol")) {56 centroid.put("lamp_mount", "wall mounted");57 } else if (centroid.get("lamp_model:fr").contains("au sol") && !centroid.get("lamp_model:fr").contains("mural")) {58 centroid.put("lamp_mount", "ground");59 } else {60 centroid.put("lamp_mount", "pole");61 }62 centroid.remove("Info");63 }64 65 /*if (dataPrimitive.get("Info") == null) {66 System.err.println("Found no primitive with tag 'Info'");67 } else if (dataPrimitive.get("Info").equals("LEA")) {//LEA;Lanterne électrique axiale;2834;eclairage_public.zip;Niveau 1868 } else if (dataPrimitive.get("Info").equals("LEL")) {//LEL;Lampadaire électrique;61337;eclairage_public.zip;Niveau 1869 } else if (dataPrimitive.get("Info").equals("LEM")) {//LEM;Lanterne électrique murale;789;eclairage_public.zip;Niveau 1870 } else if (dataPrimitive.get("Info").equals("LEMB")) {//LEMB;Lanterne électrique murale bord;14727;eclairage_public.zip;Niveau 1871 } else if (dataPrimitive.get("Info").equals("LEMRND")) {//LEMRND;Lanterne électrique murale renvoi à droite;5635;eclairage_public.zip;Niveau 1872 } else if (dataPrimitive.get("Info").equals("LEMRNG")) {//LEMRNG;Lanterne électrique murale renvoi à gauche;3822;eclairage_public.zip;Niveau 1873 } else if (dataPrimitive.get("Info").equals("LERRND")) {//LERRND;Lanterne électrique murale et boite raccord BT renvoi à droite;5657;eclairage_public.zip;Niveau 1874 } else if (dataPrimitive.get("Info").equals("LERRNG")) {//LERRNG;Lanterne électrique murale et boite raccord BT renvoi à gauche;3377;eclairage_public.zip;Niveau 1875 } else if (dataPrimitive.get("Info").equals("LSO")) {//LSO;Lanterne au sol;1337;eclairage_public.zip;Niveau 1876 } else if (dataPrimitive.get("Info").equals("PHO")) {//PHO;Poteau horaire;17;eclairage_public.zip;Niveau 1877 } else if (dataPrimitive.get("Info").equals("PPEP")) {//PPEP;Poteau provisoire d'éclairage public;181;eclairage_public.zip;Niveau 1878 } else if (dataPrimitive.get("Info").equals("PPR")) {//PPR;poteau à projecteur;67;eclairage_public.zip;Niveau 1879 } else if (dataPrimitive.get("Info").equals("PRJ")) {//PRJ;Projecteur au sol ou mural;1864;eclairage_public.zip;Niveau 1880 } else if (dataPrimitive.get("Info").equals("PRJRND")) {//PRJRND;Projecteur au sol ou mural renvoi à droite;42;eclairage_public.zip;Niveau 1881 } else if (dataPrimitive.get("Info").equals("PRJRNG")) {//PRJRNG;Projecteur au sol ou mural renvoi à gauche;57;eclairage_public.zip;Niveau 1882 } else {83 System.err.println("Unsupported Info: "+dataPrimitive.get("Info"));84 }*/85 }86 }87 }88 89 @Override90 public void updateDataSet(DataSet ds) {91 // Done in notifyFeatureParsed() for drastic performance reasons92 shpHandler.nodes.clear();93 }28 @Override 29 protected String getDirectLink() { 30 return PORTAL+"hn/eclairage_public.zip"; 31 } 32 33 private final class InternalShpHandler extends ParisShpHandler { 34 35 @Override 36 public void notifyFeatureParsed(Object feature, DataSet result, Set<OsmPrimitive> featurePrimitives) { 37 initFeaturesPrimitives(featurePrimitives); 38 if (dataPrimitive == null) { 39 System.err.println("Found no primitive with tags"); 40 } else if (closedWay == null) { 41 // ;Objet sans identification particulière pour ce niveau et cette thématique;147;eclairage_public.zip;Niveau 18 42 dataPrimitive.put("FIXME", "This way is not closed and has not been recognized as highway=street_lamp."); 43 } else { 44 Node centroid = createOrGetNode(result, Geometry.getCentroid(closedWay.getNodes())); 45 if (!centroid.hasKeys()) { 46 centroid.setKeys(dataPrimitive.getKeys()); 47 centroid.put("highway", "street_lamp"); 48 replace(centroid, "Libelle", "lamp_model:fr"); 49 } else if (centroid.get("lamp_model:fr") != null && (dataPrimitive.get("Libelle") == null || !dataPrimitive.get("Libelle").equals(centroid.get("lamp_model:fr")))) { 50 System.err.println("Found 2 street lamps at the same position with different types: '"+centroid.get("lamp_model:fr")+"' and '"+dataPrimitive.get("Libelle")+"'."); 51 } 52 removePrimitives(result); 53 54 if (centroid.get("lamp_model:fr") != null) { 55 if (centroid.get("lamp_model:fr").contains("mural") && !centroid.get("lamp_model:fr").contains("au sol")) { 56 centroid.put("lamp_mount", "wall mounted"); 57 } else if (centroid.get("lamp_model:fr").contains("au sol") && !centroid.get("lamp_model:fr").contains("mural")) { 58 centroid.put("lamp_mount", "ground"); 59 } else { 60 centroid.put("lamp_mount", "pole"); 61 } 62 centroid.remove("Info"); 63 } 64 65 /*if (dataPrimitive.get("Info") == null) { 66 System.err.println("Found no primitive with tag 'Info'"); 67 } else if (dataPrimitive.get("Info").equals("LEA")) { // LEA;Lanterne électrique axiale;2834;eclairage_public.zip;Niveau 18 68 } else if (dataPrimitive.get("Info").equals("LEL")) { // LEL;Lampadaire électrique;61337;eclairage_public.zip;Niveau 18 69 } else if (dataPrimitive.get("Info").equals("LEM")) { // LEM;Lanterne électrique murale;789;eclairage_public.zip;Niveau 18 70 } else if (dataPrimitive.get("Info").equals("LEMB")) { // LEMB;Lanterne électrique murale bord;14727;eclairage_public.zip;Niveau 18 71 } else if (dataPrimitive.get("Info").equals("LEMRND")) { // LEMRND;Lanterne électrique murale renvoi à droite;5635;eclairage_public.zip;Niveau 18 72 } else if (dataPrimitive.get("Info").equals("LEMRNG")) { // LEMRNG;Lanterne électrique murale renvoi à gauche;3822;eclairage_public.zip;Niveau 18 73 } else if (dataPrimitive.get("Info").equals("LERRND")) { // LERRND;Lanterne électrique murale et boite raccord BT renvoi à droite;5657;eclairage_public.zip;Niveau 18 74 } else if (dataPrimitive.get("Info").equals("LERRNG")) { // LERRNG;Lanterne électrique murale et boite raccord BT renvoi à gauche;3377;eclairage_public.zip;Niveau 18 75 } else if (dataPrimitive.get("Info").equals("LSO")) { // LSO;Lanterne au sol;1337;eclairage_public.zip;Niveau 18 76 } else if (dataPrimitive.get("Info").equals("PHO")) { // PHO;Poteau horaire;17;eclairage_public.zip;Niveau 18 77 } else if (dataPrimitive.get("Info").equals("PPEP")) { // PPEP;Poteau provisoire d'éclairage public;181;eclairage_public.zip;Niveau 18 78 } else if (dataPrimitive.get("Info").equals("PPR")) { // PPR;poteau à projecteur;67;eclairage_public.zip;Niveau 18 79 } else if (dataPrimitive.get("Info").equals("PRJ")) { // PRJ;Projecteur au sol ou mural;1864;eclairage_public.zip;Niveau 18 80 } else if (dataPrimitive.get("Info").equals("PRJRND")) { // PRJRND;Projecteur au sol ou mural renvoi à droite;42;eclairage_public.zip;Niveau 18 81 } else if (dataPrimitive.get("Info").equals("PRJRNG")) { // PRJRNG;Projecteur au sol ou mural renvoi à gauche;57;eclairage_public.zip;Niveau 18 82 } else { 83 System.err.println("Unsupported Info: "+dataPrimitive.get("Info")); 84 }*/ 85 } 86 } 87 } 88 89 @Override 90 public void updateDataSet(DataSet ds) { 91 // Done in notifyFeatureParsed() for drastic performance reasons 92 shpHandler.nodes.clear(); 93 } 94 94 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/urbanisme/SanisettesHandler.java
r30701 r30731 15 15 public class SanisettesHandler extends ParisDataSetHandler { 16 16 17 public SanisettesHandler() {18 super(93);19 setName("Sanisettes");20 getShpHandler().setCheckNodeProximity(true);21 }17 public SanisettesHandler() { 18 super(93); 19 setName("Sanisettes"); 20 getShpHandler().setCheckNodeProximity(true); 21 } 22 22 23 @Override24 public boolean acceptsFilename(String filename) {25 return acceptsShpFilename(filename, "sanisettes") || acceptsZipFilename(filename, "sanisettes");26 }23 @Override 24 public boolean acceptsFilename(String filename) { 25 return acceptsShpFilename(filename, "sanisettes") || acceptsZipFilename(filename, "sanisettes"); 26 } 27 27 28 private boolean wayBelongsTo(Way a, List<Way> ways) {29 for (Way b : ways) {30 if (a.getNode(0).equals(b.getNode(0)) || a.getNode(0).equals(b.getNode(b.getNodesCount()-1))31 || a.getNode(a.getNodesCount()-1).equals(b.getNode(0)) || a.getNode(a.getNodesCount()-1).equals(b.getNode(b.getNodesCount()-1))) {32 return true;33 }34 }35 return false;36 }37 38 private boolean wayProcessed(Way a, List<List<Way>> waysToCombine) {39 for (List<Way> ways : waysToCombine) {40 for (Way b : ways) {41 if (a.equals(b)) {42 return true;43 }44 }45 }46 return false;47 }48 49 @Override50 public void updateDataSet(DataSet ds) {51 52 List<Way> sourceWays = new ArrayList<>(ds.getWays());53 List<List<Way>> waysToCombine = new ArrayList<>();54 55 for (Iterator<Way> it = sourceWays.iterator(); it.hasNext();) {56 Way w = it.next();57 it.remove();58 if (!wayProcessed(w, waysToCombine)) {59 List<Way> list = new ArrayList<>();60 list.add(w);61 boolean finished = false;62 List<Way> sourceWays2 = new ArrayList<>(sourceWays);63 while (!finished) {64 int before = list.size();65 for (Iterator<Way> it2 = sourceWays2.iterator(); it2.hasNext();) {66 Way w2 = it2.next();67 if (wayBelongsTo(w2, list)) {68 list.add(w2);69 it2.remove();70 }71 }72 int after = list.size();73 finished = (after == before);74 }75 if (list.size() > 1) {76 waysToCombine.add(list);77 }78 }79 }80 81 for (List<Way> ways : waysToCombine) {82 try {83 WayCombiner.combineWays(ways);84 } catch (UserCancelException e) {85 return;86 }87 }88 89 for (Way w : ds.getWays()) {90 if (w.getNodesCount() <= 3) {91 ds.removePrimitive(w);92 for (Node n : w.getNodes()) {93 ds.removePrimitive(n);94 }95 } else {96 w.put("amenity", "toilets");97 }98 }99 }28 private boolean wayBelongsTo(Way a, List<Way> ways) { 29 for (Way b : ways) { 30 if (a.getNode(0).equals(b.getNode(0)) || a.getNode(0).equals(b.getNode(b.getNodesCount()-1)) 31 || a.getNode(a.getNodesCount()-1).equals(b.getNode(0)) || a.getNode(a.getNodesCount()-1).equals(b.getNode(b.getNodesCount()-1))) { 32 return true; 33 } 34 } 35 return false; 36 } 37 38 private boolean wayProcessed(Way a, List<List<Way>> waysToCombine) { 39 for (List<Way> ways : waysToCombine) { 40 for (Way b : ways) { 41 if (a.equals(b)) { 42 return true; 43 } 44 } 45 } 46 return false; 47 } 48 49 @Override 50 public void updateDataSet(DataSet ds) { 51 52 List<Way> sourceWays = new ArrayList<>(ds.getWays()); 53 List<List<Way>> waysToCombine = new ArrayList<>(); 54 55 for (Iterator<Way> it = sourceWays.iterator(); it.hasNext();) { 56 Way w = it.next(); 57 it.remove(); 58 if (!wayProcessed(w, waysToCombine)) { 59 List<Way> list = new ArrayList<>(); 60 list.add(w); 61 boolean finished = false; 62 List<Way> sourceWays2 = new ArrayList<>(sourceWays); 63 while (!finished) { 64 int before = list.size(); 65 for (Iterator<Way> it2 = sourceWays2.iterator(); it2.hasNext();) { 66 Way w2 = it2.next(); 67 if (wayBelongsTo(w2, list)) { 68 list.add(w2); 69 it2.remove(); 70 } 71 } 72 int after = list.size(); 73 finished = (after == before); 74 } 75 if (list.size() > 1) { 76 waysToCombine.add(list); 77 } 78 } 79 } 80 81 for (List<Way> ways : waysToCombine) { 82 try { 83 WayCombiner.combineWays(ways); 84 } catch (UserCancelException e) { 85 return; 86 } 87 } 88 89 for (Way w : ds.getWays()) { 90 if (w.getNodesCount() <= 3) { 91 ds.removePrimitive(w); 92 for (Node n : w.getNodes()) { 93 ds.removePrimitive(n); 94 } 95 } else { 96 w.put("amenity", "toilets"); 97 } 98 } 99 } 100 100 101 @Override102 protected String getDirectLink() {103 return PORTAL+"hn/sanisettes.zip";104 }101 @Override 102 protected String getDirectLink() { 103 return PORTAL+"hn/sanisettes.zip"; 104 } 105 105 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/urbanisme/VolumesBatisHandler.java
r30340 r30731 7 7 public class VolumesBatisHandler extends ParisDataSetHandler { 8 8 9 public VolumesBatisHandler() {10 super(80);11 setName("Volumes bâtis");12 }9 public VolumesBatisHandler() { 10 super(80); 11 setName("Volumes bâtis"); 12 } 13 13 14 @Override15 public boolean acceptsFilename(String filename) {16 return acceptsShpFilename(filename, "VOL_BATI") || acceptsZipFilename(filename, "VOL_BATI");17 }18 19 @Override20 public void updateDataSet(DataSet ds) {21 // TODO22 }14 @Override 15 public boolean acceptsFilename(String filename) { 16 return acceptsShpFilename(filename, "VOL_BATI") || acceptsZipFilename(filename, "VOL_BATI"); 17 } 18 19 @Override 20 public void updateDataSet(DataSet ds) { 21 // TODO 22 } 23 23 24 @Override25 protected String getDirectLink() {26 return PORTAL+"hn/VOL_BATI.zip";27 }24 @Override 25 protected String getDirectLink() { 26 return PORTAL+"hn/VOL_BATI.zip"; 27 } 28 28 } -
applications/editors/josm/plugins/opendata/modules/fr.paris/src/org/openstreetmap/josm/plugins/opendata/modules/fr/paris/datasets/urbanisme/VolumesNonBatisHandler.java
r30340 r30731 7 7 public class VolumesNonBatisHandler extends ParisDataSetHandler { 8 8 9 public VolumesNonBatisHandler() {10 super(106);11 setName("Volumes non bâtis");12 }9 public VolumesNonBatisHandler() { 10 super(106); 11 setName("Volumes non bâtis"); 12 } 13 13 14 @Override15 public boolean acceptsFilename(String filename) {16 return acceptsShpFilename(filename, "VOL_NBATI") || acceptsZipFilename(filename, "VOL_NBATI");17 }18 19 @Override20 public void updateDataSet(DataSet ds) {21 // TODO22 }14 @Override 15 public boolean acceptsFilename(String filename) { 16 return acceptsShpFilename(filename, "VOL_NBATI") || acceptsZipFilename(filename, "VOL_NBATI"); 17 } 18 19 @Override 20 public void updateDataSet(DataSet ds) { 21 // TODO 22 } 23 23 24 @Override25 protected String getDirectLink() {26 return PORTAL+"hn/VOL_NBATI.zip";27 }24 @Override 25 protected String getDirectLink() { 26 return PORTAL+"hn/VOL_NBATI.zip"; 27 } 28 28 }
Note:
See TracChangeset
for help on using the changeset viewer.
