Changeset 34168 in osm


Ignore:
Timestamp:
2018-04-24T07:48:05+02:00 (6 years ago)
Author:
mkyral
Message:

PointInfo: Add Spanish Cadastre Web Services module.

Patch by Javier Sánchez Portero.

Location:
applications/editors/josm/plugins/pointInfo
Files:
11 added
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pointInfo/README.md

    r34095 r34168  
    66
    77This plugin shows all available information for clicked point from external database.
    8 There is only a Czech RUIAN module available at this moment.
     8Only Czech RUIAN and Spanish Cadastre Web Services modules are available at this moment.
    99
    1010Plugin could be easy extend to show another data source.
    1111
    12 ##Author
     12## Author
    1313
    1414 * Marián Kyral <mkyral@email.cz>
    1515
    16 ##Websites
     16## Contributors
     17
     18  * Javier Sánchez Portero <javiersanp@gmail.com> (Spanish Cadastre Web Services module)
     19
     20## Websites
    1721
    1822 * OSM wiki - not available yet
     
    2024 * [Github](https://github.com/mkyral/josm-pointInfo)
    2125
    22 ##Licence:
     26## Licence:
    2327
    2428 * GPL v2 or later
    2529
    2630---
    27 ###The RUIAN module
     31### The RUIAN module
    2832
    2933 * Shows data about building, addresses, streets,  parcels and cadastral area from Czech RUIAN registry (https://wiki.openstreetmap.org/wiki/RUIAN)
     
    3741    * [![](https://raw.githubusercontent.com/mkyral/josm-pointInfo/master/images/dialogs/create-bug-report.png)] Report an issue with building
    3842
     43### The Spanish Cadastre Web Services module
     44
     45  * Easy access the Spanish Cadastre Web Services (only Cadastre photographs at the moment).
     46
    3947---
    40 ###The interface:
     48### The interface:
    4149
    4250- Input is position, output html string that is shown on message.
  • applications/editors/josm/plugins/pointInfo/build.xml

    r33615 r34168  
    33
    44    <!-- enter the SVN commit message -->
    5     <property name="commit.message" value="PointInfo: Replace depricated AddCommand function."/>
     5    <property name="commit.message" value="PointInfo: Add Spanish Cadastre Web Services module. Patch by Javier Sánchez Portero."/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    77    <property name="plugin.main.version" value="12666"/>
     
    1515    <property name="plugin.author" value="Marián Kyral"/>
    1616    <property name="plugin.class" value="org.openstreetmap.josm.plugins.pointinfo.PointInfoPlugin"/>
    17     <property name="plugin.description" value="Shows an additional information about point on map. There is only a Czech RUIAN module available at this moment."/>
     17    <property name="plugin.description" value="Shows an additional information about point on map. Only Czech RUIAN and Spanish Cadastre Web Services modules are available at this moment."/>
    1818    <property name="plugin.icon" value="images/mapmode/info-sml.png"/>
    1919    <property name="plugin.link" value="https://github.com/mkyral/josm-pointInfo"/>
  • applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoAction.java

    r33549 r34168  
    2525import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2626import org.openstreetmap.josm.gui.util.GuiHelper;
    27 import org.openstreetmap.josm.plugins.pointinfo.ruian.RuianModule;
     27import org.openstreetmap.josm.plugins.pointinfo.AbstractPointInfoModule;
    2828import org.openstreetmap.josm.tools.ImageProvider;
    2929import org.openstreetmap.josm.tools.Logging;
     
    3737
    3838    protected boolean cancel;
    39     protected RuianModule mRuian = new RuianModule();
     39    protected AbstractPointInfoModule module;
    4040
    4141    private String htmlText = "";
     
    7676
    7777        try {
     78            module = PointInfoPlugin.getModule(pos);
    7879            PleaseWaitRunnable infoTask = new PleaseWaitRunnable(tr("Connecting server")) {
    7980                @Override
     
    9596                        msgLabel.addHyperlinkListener(hle -> {
    9697                            if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
     98                                Logging.info(hle.getURL().toString());
    9799                                if (hle.getURL() == null || hle.getURL().toString().isEmpty()) {
    98100                                    return;
    99101                                }
    100                                 System.out.println("URL: "+ hle.getURL());
    101102                                if (!hle.getURL().toString().startsWith("http")) {
    102                                     mRuian.performAction(hle.getURL().toString());
     103                                    module.performAction(hle.getURL().toString());
    103104                                } else {
    104105                                    String ret = OpenBrowser.displayUrl(hle.getURL().toString());
     
    132133        progressMonitor.beginTask(null, 3);
    133134        try {
    134             mRuian.prepareData(pos);
    135             htmlText = mRuian.getHtml();
     135            module.prepareData(pos);
     136            htmlText = module.getHtml();
    136137            coordinatesText = PointInfoUtils.formatCoordinates(pos.lat(), pos.lon());
    137138
  • applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoPlugin.java

    r33549 r34168  
    22package org.openstreetmap.josm.plugins.pointinfo;
    33
     4import java.io.IOException;
     5import java.util.ArrayList;
     6import java.util.HashMap;
     7import java.util.Iterator;
     8import java.util.List;
     9
     10import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.data.coor.LatLon;
     12import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    413import org.openstreetmap.josm.gui.MainApplication;
    514import org.openstreetmap.josm.gui.MainMenu;
    615import org.openstreetmap.josm.plugins.Plugin;
    716import org.openstreetmap.josm.plugins.PluginInformation;
     17import org.openstreetmap.josm.plugins.pointinfo.ruian.RuianModule;
     18import org.openstreetmap.josm.plugins.pointinfo.catastro.CatastroModule;
    819
    920/**
     
    1223 */
    1324public class PointInfoPlugin extends Plugin {
     25
     26    private static final HashMap<String, AbstractPointInfoModule> modules = new HashMap<>();
     27    static {
     28        registerModule(new RuianModule());
     29        registerModule(new CatastroModule());
     30    }
    1431
    1532    /**
     
    2138        MainMenu.add(MainApplication.getMenu().moreToolsMenu, new PointInfoAction());
    2239    }
     40
     41    @Override
     42    public PreferenceSetting getPreferenceSetting() {
     43        return new PointInfoPreference();
     44    }
     45
     46    /**
     47     * Register a module as available to select in the preferences.
     48     * @param module PointInfo module
     49     */
     50    public static void registerModule(AbstractPointInfoModule module) {
     51        modules.put(module.getName(), module);
     52    }
     53
     54    /**
     55     * Returns a list of available modules names
     56     * @return modsList
     57     */
     58    public static List<String> getModules() {
     59        return new ArrayList<>(modules.keySet());
     60    }
     61
     62    /**
     63     * Returns a valid module for this point. If auto mode is selected, returns
     64     * the first valid module for the area in the given position
     65     the currently selected module
     66     * @param pos position LatLon
     67     * @return module
     68     * @throws IOException if any IO error occurs.
     69    */
     70    public static AbstractPointInfoModule getModule(LatLon pos) throws IOException {
     71        AbstractPointInfoModule module;
     72        module = null;
     73        if (Main.pref.getBoolean("plugin.pointinfo.automode", true)) {
     74            ReverseRecord r = ReverseFinder.queryNominatim(pos);
     75            Iterator i = modules.values().iterator();
     76            while (module == null && i.hasNext()) {
     77                AbstractPointInfoModule m = (AbstractPointInfoModule) i.next();
     78                if (r.matchAnyArea(m.getArea())) {
     79                    module = m;
     80                }
     81            }
     82        } else {
     83            module = modules.get(Main.pref.get("plugin.pointinfo.module", "RUIAN"));
     84        }
     85        if (module == null) {
     86            module = modules.get("RUIAN");
     87        }
     88        return module;
     89    }
    2390}
  • applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoUtils.java

    r32848 r34168  
    3838    /**
    3939     * Return text representation of coordinates.
    40      # @param  lat Lat coordinate
    41      # @param  lon Lon coordinate
     40     * @param lat the lat part of coordinates
     41     * @param lon the lon part of coordinates
    4242     * @return String coordinatesText
    4343     */
  • applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruian/RuianModule.java

    r33549 r34168  
    88import org.openstreetmap.josm.tools.Logging;
    99
     10import org.openstreetmap.josm.plugins.pointinfo.AbstractPointInfoModule;
     11
    1012/**
    1113 * A module for the Czech RUIAN database
    1214 * @author Marián Kyral
    1315 */
    14 public class RuianModule {
     16public class RuianModule extends AbstractPointInfoModule {
    1517
    16     private String URL = "http://josm.poloha.net/pointInfo/v4/index.php";
     18    private static final String moduleName = "RUIAN";
     19    private static final String areaName = "cz";
     20    private static final String URL = "http://josm.poloha.net/pointInfo/v4/index.php";
    1721
    1822    private RuianRecord m_record = new RuianRecord();
     
    2226    }
    2327
    24     /**
    25      * Return Html text representation
    26      * @return String htmlText
    27      */
     28    @Override
    2829    public String getHtml() {
    2930        return m_record.getHtml();
    3031    }
    3132
    32     /**
    33      * Perform given action
    34      *  e.g.: copy tags to clipboard
    35      * @param act Action to be performed
    36      */
     33    @Override
    3734    public void performAction(String act) {
    3835        m_record.performAction(act);
     
    4340     * @param pos Position on the map
    4441     */
     42    @Override
    4543    public void prepareData(LatLon pos) {
    4644        try {
     
    5149        }
    5250    }
     51
     52    @Override
     53    public String getName() {
     54        return moduleName;   
     55    }
     56
     57    @Override
     58    public String getArea() {
     59        return areaName;
     60    }
    5361}
Note: See TracChangeset for help on using the changeset viewer.