Changeset 35269 in osm


Ignore:
Timestamp:
2020-01-11T16:18:11+01:00 (5 years ago)
Author:
donvip
Message:

update to JOSM 15419 + add unit test for Toulouse module

Location:
applications/editors/josm/plugins/opendata
Files:
5 added
15 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/.classpath

    r34452 r35269  
    22<classpath>
    33        <classpathentry kind="src" path="src"/>
     4        <classpathentry including="images/" kind="src" path=""/>
    45        <classpathentry excluding="org/odftoolkit/odfdom/JarManifest.java|org/odftoolkit/simple/JarManifest.java|org/odftoolkit/simple/|org/jopendocument/dom/spreadsheet/SheetTest.java|org/jopendocument/dom/ChildCreatorTest.java|org/jopendocument/dom/ODSingleXMLDocumentTest.java|org/jopendocument/dom/OOXMLTest.java|org/jopendocument/dom/template/|org/jopendocument/sample/|org/jopendocument/util/cache/ICacheTest.java|org/jopendocument/panel/|org/jopendocument/tools/|org/jopendocument/print/|org/jopendocument/renderer/|org/jopendocument/util/BenchmarkUtilities.java|org/jopendocument/util/ImageUtilities.java|org/jopendocument/util/PrintUtilities.java|org/odftoolkit/odfdom/|org/jopendocument/util/CompareUtils.java|org/jopendocument/util/DummyGraphics2D.java|org/jopendocument/util/DummyFontMetrics.java|org/jopendocument/dom/spreadsheet/CalcNode.java|org/jopendocument/io/StyleTableProperties.java|org/jopendocument/util/ReflectUtils.java|org/jopendocument/util/cache/CacheWatcher.java|org/jopendocument/util/cache/CacheWatcherFactory.java|org/jopendocument/util/cache/ICache.java|org/jopendocument/util/cache/|org/jopendocument/util/cc/ExnTransformer.java|org/jopendocument/model/chart/ChartChart.java|org/jopendocument/model/ConfigConfigItem.java|org/jopendocument/dom/text/Heading.java|org/odftoolkit/" kind="src" path="includes"/>
    56        <classpathentry kind="src" path="resources"/>
  • applications/editors/josm/plugins/opendata/build.xml

    r35179 r35269  
    11<?xml version="1.0" encoding="utf-8"?>
    22<project name="opendata" default="dist" basedir=".">
    3     <property name="plugin.main.version" value="15386"/>
     3    <property name="plugin.main.version" value="15419"/>
    44    <property name="plugin.author" value="Don-vip"/>
    55    <property name="plugin.class" value="org.openstreetmap.josm.plugins.opendata.OdPlugin"/>
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModule.java

    r33518 r35269  
    33
    44import java.util.Collection;
    5 import java.util.Comparator;
    65import java.util.TreeSet;
    76
     
    5958import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.urbanisme.SanisetteHandler;
    6059import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.datasets.urbanisme.VoirieHandler;
     60import org.openstreetmap.josm.tools.Logging;
    6161
     62/**
     63 * Open data module for Toulouse portal.
     64 */
    6265public class ToulouseModule extends AbstractModule {
    6366
     
    112115    public static final DataSet data = new DataSet();
    113116
    114     private static final Collection<Relation> getBoundaries(int admin_level) {
    115         Collection<Relation> result = new TreeSet<>(new Comparator<Relation>() {
    116             @Override
    117             public int compare(Relation o1, Relation o2) {
    118                 if (o1.hasKey("name") && o2.hasKey("name")) {
    119                     return o1.get("name").compareTo(o2.get("name"));
    120                 } else if (o1.hasKey("ref") && o2.hasKey("ref")) {
    121                     return o1.get("ref").compareTo(o2.get("ref"));
    122                 } else {
    123                     return o1.get("description").compareTo(o2.get("description"));
    124                 }
     117    private static Collection<Relation> getBoundaries(int adminLevel) {
     118        Collection<Relation> result = new TreeSet<>((o1, o2) -> {
     119            if (o1.hasKey("name") && o2.hasKey("name")) {
     120                return o1.get("name").compareTo(o2.get("name"));
     121            } else if (o1.hasKey("ref") && o2.hasKey("ref")) {
     122                return o1.get("ref").compareTo(o2.get("ref"));
     123            } else {
     124                return o1.get("description").compareTo(o2.get("description"));
    125125            }
    126126        });
    127127        synchronized (data) {
    128128            for (Relation r : data.getRelations()) {
    129                 if (r.hasTag("admin_level", Integer.toString(admin_level)) &&
     129                if (r.hasTag("admin_level", Integer.toString(adminLevel)) &&
    130130                        (r.hasKey("name") || r.hasKey("ref") || r.hasKey("description"))) {
    131131                    result.add(r);
     
    141141                for (final ToulouseDataSetHandler handler : new ToulouseDataSetHandler[]{
    142142                        new CommuneHandler(), new SecteursHandler(), new QuartiersHandler()}) {
    143                     MainApplication.worker.submit(new Runnable() {
    144                         @Override
    145                         public void run() {
    146                             try {
    147                                 DataSet ds = new NetworkReader(handler.getDataURL().toString(), handler, false).
    148                                         parseOsm(NullProgressMonitor.INSTANCE);
    149                                 handler.updateDataSet(ds);
    150                                 synchronized (data) {
    151                                     data.mergeFrom(ds);
    152                                 }
    153                             } catch (OsmTransferException e) {
    154                                 e.printStackTrace();
     143                    MainApplication.worker.submit(() -> {
     144                        try {
     145                            DataSet ds = new NetworkReader(handler.getDataURL().toString(), handler, false).
     146                                    parseOsm(NullProgressMonitor.INSTANCE);
     147                            handler.updateDataSet(ds);
     148                            synchronized (data) {
     149                                data.mergeFrom(ds);
    155150                            }
     151                        } catch (OsmTransferException e) {
     152                            Logging.error(e);
    156153                        }
    157154                    });
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/ToulouseDataSetHandler.java

    r33518 r35269  
    3535import org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse.ToulouseModule;
    3636import org.openstreetmap.josm.plugins.utilsplugin2.selection.NodeWayUtils;
     37import org.openstreetmap.josm.tools.Logging;
    3738
    3839public abstract class ToulouseDataSetHandler extends FrenchDataSetHandler implements ToulouseConstants {
     
    4142     * Categories
    4243     */
    43     public static final DataSetCategory CAT_ASSOCIATIONS = new DataSetCategory("Associations", "styles/standard/people.png");
    44     public static final DataSetCategory CAT_CITOYENNETE = new DataSetCategory("Citoyenneté", "presets/townhall.png");
    45     public static final DataSetCategory CAT_CULTURE = new DataSetCategory("Culture", "presets/arts_centre.png");
    46     public static final DataSetCategory CAT_ENFANCE = new DataSetCategory("Enfance", "presets/kindergarten.png");
     44    public static final DataSetCategory CAT_ASSOCIATIONS = new DataSetCategory("Associations", "people.png");
     45    public static final DataSetCategory CAT_CITOYENNETE = new DataSetCategory("Citoyenneté", "presets/service/townhall.svg");
     46    public static final DataSetCategory CAT_CULTURE = new DataSetCategory("Culture", "presets/sightseeing/arts_centre.svg");
     47    public static final DataSetCategory CAT_ENFANCE = new DataSetCategory("Enfance", "presets/education/kindergarten.svg");
    4748    public static final DataSetCategory CAT_ENVIRONNEMENT = new DataSetCategory("Environnement",
    48             "styles/standard/service/recycling/recycling_container.svg");
    49     public static final DataSetCategory CAT_PATRIMOINE = new DataSetCategory("Patrimoine", "presets/ruins.png");
    50     public static final DataSetCategory CAT_SERVICES = new DataSetCategory("Services", "styles/standard/vehicle/services.png");
    51     public static final DataSetCategory CAT_SPORT = new DataSetCategory("Sport", "styles/standard/sport/soccer.png");
    52     public static final DataSetCategory CAT_TOPOGRAPHIE = new DataSetCategory("Topographie", "presets/peak.svg");
    53     public static final DataSetCategory CAT_TRANSPORT = new DataSetCategory("Transport", "presets/bus.png");
    54     public static final DataSetCategory CAT_URBANISME = new DataSetCategory("Urbanisme", "styles/standard/place/settlement/city.png");
     49            "presets/service/recycling/recycling_container.svg");
     50    public static final DataSetCategory CAT_PATRIMOINE = new DataSetCategory("Patrimoine", "presets/sightseeing/ruins.svg");
     51    public static final DataSetCategory CAT_SERVICES = new DataSetCategory("Services", "presets/vehicle/services.svg");
     52    public static final DataSetCategory CAT_SPORT = new DataSetCategory("Sport", "presets/sport/soccer.svg");
     53    public static final DataSetCategory CAT_TOPOGRAPHIE = new DataSetCategory("Topographie", "presets/landmark/peak.svg");
     54    public static final DataSetCategory CAT_TRANSPORT = new DataSetCategory("Transport", "presets/transport/bus.svg");
     55    public static final DataSetCategory CAT_URBANISME = new DataSetCategory("Urbanisme", "presets/place/city.svg");
    5556
    5657    public ToulouseDataSetHandler(int portalId) {
     
    6364    }
    6465
    65     public ToulouseDataSetHandler(int portalId, boolean relevantUnion, String ... relevantTags) {
     66    public ToulouseDataSetHandler(int portalId, boolean relevantUnion, String... relevantTags) {
    6667        super(relevantUnion, relevantTags);
    6768        init(portalId);
    6869    }
    6970
    70     public ToulouseDataSetHandler(int portalId, String ... relevantTags) {
     71    public ToulouseDataSetHandler(int portalId, String... relevantTags) {
    7172        this(portalId, false, relevantTags);
    7273    }
    7374
    74     /*public ToulouseDataSetHandler(int portalId, Tag relevantTag) {
    75         super(relevantTag);
    76         init(portalId);
    77     }*/
    78 
    79     public ToulouseDataSetHandler(int portalId, boolean relevantUnion, Tag ... relevantTags) {
     75    public ToulouseDataSetHandler(int portalId, boolean relevantUnion, Tag... relevantTags) {
    8076        super(relevantUnion, relevantTags);
    8177        init(portalId);
    8278    }
    83 
    84     /*public ToulouseDataSetHandler(int portalId, Tag ... relevantTags) {
    85         this(portalId, false, relevantTags);
    86     }*/
    8779
    8880    private void init(int portalId) {
     
    9284                String url = PORTAL + "/les-donnees/-/opendata/card/" + portalId + "--";
    9385                setLocalPortalURL(url);
    94                 //setLicenseURL(url+"/license");
    9586                setDataURL(url+"/resource/document");
    9687            }
     
    9990            addTool(new SplitByNeighbourhood());
    10091        } catch (MalformedURLException e) {
    101             e.printStackTrace();
     92            Logging.error(e);
    10293        }
    10394    }
     
    124115                setWikiURL(WIKI + "/" + wikiPage.replace(" ", "_"));
    125116            } catch (MalformedURLException e) {
    126                 e.printStackTrace();
     117                Logging.error(e);
    127118            }
    128119        }
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/QuartiersHandler.java

    r30340 r35269  
    1212        setWikiPage("Quartiers de proximité");
    1313        setCategory(CAT_CITOYENNETE);
    14         setMenuIcon("presets/boundaries.png");
     14        setMenuIcon("presets/misc/boundaries.svg");
    1515    }
    1616
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/citoyennete/SecteursHandler.java

    r30340 r35269  
    1212        setWikiPage("Secteurs de proximité");
    1313        setCategory(CAT_CITOYENNETE);
    14         setMenuIcon("presets/boundaries.png");
     14        setMenuIcon("presets/misc/boundaries.svg");
    1515    }
    1616
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/HorodateurHandler.java

    r33518 r35269  
    1616        setWikiPage("Horodateurs");
    1717        setCategory(CAT_TRANSPORT);
    18         setMenuIcon("styles/standard/transport/ticket-machine.png");
     18        setMenuIcon("presets/transport/ticket-machine.svg");
    1919    }
    2020
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/MetroStationHandler.java

    r30340 r35269  
    1212        setName("Stations de métro");
    1313        setCategory(CAT_TRANSPORT);
    14         setMenuIcon("styles/standard/transport/railway_station.png");
     14        setMenuIcon("presets/transport/railway_station.svg");
    1515    }
    1616
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/PMRHandler.java

    r30340 r35269  
    1212        setWikiPage("PMR");
    1313        setCategory(CAT_TRANSPORT);
    14         setMenuIcon("styles/standard/vehicle/parking/handicapped.png");
     14        setMenuIcon("presets/vehicle/parking/handicapped.svg");
    1515    }
    1616
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/transport/TramwayStationHandler.java

    r30340 r35269  
    1212        setName("Stations de tramway");
    1313        setCategory(CAT_TRANSPORT);
    14         setMenuIcon("styles/standard/transport/railway_station.png");
     14        setMenuIcon("presets/transport/railway_station.svg");
    1515    }
    1616
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/CommuneHandler.java

    r30340 r35269  
    1212        setName("Communes");
    1313        setCategory(CAT_URBANISME);
    14         setMenuIcon("presets/boundaries.png");
     14        setMenuIcon("presets/misc/boundaries.svg");
    1515    }
    1616
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/src/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/datasets/urbanisme/VoirieHandler.java

    r31939 r35269  
    1818
    1919    protected final Map<String, Collection<String>> map = new HashMap<>();
    20    
     20
    2121    private String streetField;
    22    
     22
    2323    public VoirieHandler() {
    2424        this(12693, "lib_off", "highway");
    2525        setName("Filaire de voirie");
    2626        setCategory(CAT_URBANISME);
    27         setMenuIcon("styles/standard/transport/way/way_secondary.svg");
     27        setMenuIcon("presets/transport/way/way_secondary.svg");
    2828    }
    29    
     29
    3030    protected VoirieHandler(int portalId, String streetField, String relevantTag) {
    3131        super(portalId, relevantTag);
     
    3939        map.put("road", Arrays.asList(new String[] {"VA "}));
    4040    }
    41    
     41
    4242    @Override
    4343    public boolean acceptsFilename(String filename) {
     
    5858        return null;
    5959    }
    60    
     60
    6161    protected String getStreetId(Way w) {
    6262        return w.get("sti");
    6363    }
    64    
     64
    6565    @Override
    6666    public void updateDataSet(DataSet ds) {
    6767        Map<String, Relation> associatedStreets = new HashMap<>();
    68        
     68
    6969        for (Way w : ds.getWays()) {
    7070            String name = w.get(streetField);
     
    7575                w.remove("rivoli");
    7676                w.remove("nrivoli");
    77                
     77
    7878                if (applyHighwayTag(name, w) == null) {
    7979                    w.put("highway", "road");
    8080                }
    81                
     81
    8282                if (name.startsWith("RPT ") || name.startsWith("GIRATOIRE ")) {
    8383                    // TODO: find correct highway
     
    8686                    w.put("ref", name.split(" ")[1]);
    8787                }
    88                
     88
    8989                w.put("name", name);
    90                
     90
    9191                if (name.matches("D[0-9]+.*")) {
    9292                    w.put("highway", "secondary");
     
    9595                    name = NamesFrUtils.checkStreetName(w, "name");
    9696                }
    97                
     97
    9898                if (!name.startsWith("VA ")) { // Unknown labels
    9999                    Relation street = associatedStreets.get(getStreetId(w));
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/OdPlugin.java

    r35139 r35269  
    5151import org.openstreetmap.josm.plugins.opendata.core.modules.ModuleInformation;
    5252import org.openstreetmap.josm.plugins.opendata.core.util.OdUtils;
    53 import org.openstreetmap.josm.tools.ImageProvider;
    5453import org.openstreetmap.josm.tools.Pair;
    55 
     54import org.openstreetmap.josm.tools.ResourceProvider;
     55
     56/**
     57 * Open data plugin.
     58 */
    5659public final class OdPlugin extends Plugin {
    5760
     
    6467    private OdDialog dialog;
    6568
    66     public final List<AbstractImporter> importers =  Arrays.asList(new AbstractImporter[]{
     69    public final List<AbstractImporter> importers = Arrays.asList(new AbstractImporter[] {
    6770            new CsvImporter(), new OdsImporter(), new XlsImporter(), // Tabular file formats
    6871            new KmlKmzImporter(), new ShpImporter(), new MifTabImporter(), new GmlImporter(), // Geographic file formats
     
    7477    public OdPlugin(PluginInformation info) {
    7578        super(info);
    76         ImageProvider.addAdditionalClassLoaders(ModuleHandler.getResourceClassLoaders());
     79        ResourceProvider.addAdditionalClassLoaders(ModuleHandler.getResourceClassLoaders());
    7780        if (instance == null) {
    7881            instance = this;
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/datasets/DataSetUpdater.java

    r34452 r35269  
    2323import org.openstreetmap.josm.spi.preferences.Config;
    2424
     25/**
     26 * Data set updater.
     27 */
    2528public abstract class DataSetUpdater {
    2629
     
    4346            // Simplify ways geometries
    4447            for (Way w : dataSet.getWays()) {
    45                 SequenceCommand command = SimplifyWayAction.simplifyWay(w, 0.25);
     48                SequenceCommand command = SimplifyWayAction.createSimplifyCommand(w, 0.25);
    4649                if (command != null) {
    4750                    command.executeCommand();
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java

    r34671 r35269  
    5252import org.openstreetmap.josm.tools.ImageProvider;
    5353import org.openstreetmap.josm.tools.Logging;
     54import org.openstreetmap.josm.tools.ResourceProvider;
    5455
    5556/**
     
    289290            ClassLoader moduleClassLoader = createClassLoader(toLoad);
    290291            sources.add(0, moduleClassLoader);
    291             ImageProvider.addAdditionalClassLoader(moduleClassLoader);
     292            ResourceProvider.addAdditionalClassLoader(moduleClassLoader);
    292293            monitor.setTicksCount(toLoad.size());
    293294            for (ModuleInformation info : toLoad) {
Note: See TracChangeset for help on using the changeset viewer.