Changeset 28699 in osm for applications/editors/josm


Ignore:
Timestamp:
2012-09-08T20:52:36+02:00 (12 years ago)
Author:
donvip
Message:

[josm_opendata] Basic support for splitting by municipalities

Location:
applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModule.java

    r28696 r28699  
    120120            @Override
    121121            public int compare(Relation o1, Relation o2) {
    122                 return o1.get("ref").compareTo(o2.get("ref"));
     122                if (o1.hasKey("name") && o2.hasKey("name")) {
     123                    return o1.get("name").compareTo(o2.get("name"));
     124                } else if (o1.hasKey("ref") && o2.hasKey("ref")) {
     125                    return o1.get("ref").compareTo(o2.get("ref"));
     126                } else {
     127                    return o1.get("description").compareTo(o2.get("description"));
     128                }
    123129            }
    124130        });
     
    138144            if (data.allPrimitives().isEmpty()) {
    139145                for (final ToulouseDataSetHandler handler : new ToulouseDataSetHandler[]{
    140                         new SecteursHandler(), new QuartiersHandler()}) {
     146                        new CommuneHandler(), new SecteursHandler(), new QuartiersHandler()}) {
    141147                    Main.worker.submit(new Runnable() {
    142148                        @Override
     
    159165    }
    160166   
     167    public static final Collection<Relation> getMunicipalities() {
     168        return getBoundaries(8);
     169    }
     170   
    161171    public static final Collection<Relation> getSectors() {
    162172        return getBoundaries(10);
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/ToulouseDataSetHandler.java

    r28696 r28699  
    9292                setDataURL(url+"/resource/document");
    9393            }
     94            addTool(new SplitByMunicipality());
    9495            addTool(new SplitBySector());
    9596            addTool(new SplitByNeighbourhood());
     
    159160                    }
    160161                }
    161                 Main.main.addLayer(new OdDataLayer(data, baseName+"/"+boundary.get("ref"), null, ToulouseDataSetHandler.this));
     162                if (!data.allPrimitives().isEmpty()) {
     163                    String name = boundary.get("name");
     164                    if (name == null || name.isEmpty()) {
     165                        name = boundary.get("ref");
     166                    }
     167                    if (name == null || name.isEmpty()) {
     168                        name = boundary.get("description");
     169                    }
     170                    Main.main.addLayer(new OdDataLayer(data, baseName+"/"+name, null, ToulouseDataSetHandler.this));
     171                }
    162172            }
    163173        }
     
    189199    }
    190200   
     201    protected class SplitByMunicipality extends SplitAction {
     202        public SplitByMunicipality() {
     203            super(marktr("Split by municipality"), tr("Split this data by municipality (admin_level=8)."));
     204        }
     205        @Override
     206        protected Collection<Relation> getBoundaries() {
     207            return ToulouseModule.getMunicipalities();
     208        }
     209    }
     210
    191211    protected class SplitBySector extends SplitAction {
    192212        public SplitBySector() {
Note: See TracChangeset for help on using the changeset viewer.