Changeset 34168 in osm for applications/editors
- Timestamp:
- 2018-04-24T07:48:05+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/pointInfo
- Files:
-
- 11 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pointInfo/README.md
r34095 r34168 6 6 7 7 This plugin shows all available information for clicked point from external database. 8 There is only a Czech RUIAN module available at this moment.8 Only Czech RUIAN and Spanish Cadastre Web Services modules are available at this moment. 9 9 10 10 Plugin could be easy extend to show another data source. 11 11 12 ## Author12 ## Author 13 13 14 14 * Marián Kyral <mkyral@email.cz> 15 15 16 ##Websites 16 ## Contributors 17 18 * Javier Sánchez Portero <javiersanp@gmail.com> (Spanish Cadastre Web Services module) 19 20 ## Websites 17 21 18 22 * OSM wiki - not available yet … … 20 24 * [Github](https://github.com/mkyral/josm-pointInfo) 21 25 22 ## Licence:26 ## Licence: 23 27 24 28 * GPL v2 or later 25 29 26 30 --- 27 ### The RUIAN module31 ### The RUIAN module 28 32 29 33 * Shows data about building, addresses, streets, parcels and cadastral area from Czech RUIAN registry (https://wiki.openstreetmap.org/wiki/RUIAN) … … 37 41 * [![](https://raw.githubusercontent.com/mkyral/josm-pointInfo/master/images/dialogs/create-bug-report.png)] Report an issue with building 38 42 43 ### The Spanish Cadastre Web Services module 44 45 * Easy access the Spanish Cadastre Web Services (only Cadastre photographs at the moment). 46 39 47 --- 40 ### The interface:48 ### The interface: 41 49 42 50 - Input is position, output html string that is shown on message. -
applications/editors/josm/plugins/pointInfo/build.xml
r33615 r34168 3 3 4 4 <!-- 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."/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 7 <property name="plugin.main.version" value="12666"/> … … 15 15 <property name="plugin.author" value="Marián Kyral"/> 16 16 <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."/> 18 18 <property name="plugin.icon" value="images/mapmode/info-sml.png"/> 19 19 <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 25 25 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 26 26 import org.openstreetmap.josm.gui.util.GuiHelper; 27 import org.openstreetmap.josm.plugins.pointinfo. ruian.RuianModule;27 import org.openstreetmap.josm.plugins.pointinfo.AbstractPointInfoModule; 28 28 import org.openstreetmap.josm.tools.ImageProvider; 29 29 import org.openstreetmap.josm.tools.Logging; … … 37 37 38 38 protected boolean cancel; 39 protected RuianModule mRuian = new RuianModule();39 protected AbstractPointInfoModule module; 40 40 41 41 private String htmlText = ""; … … 76 76 77 77 try { 78 module = PointInfoPlugin.getModule(pos); 78 79 PleaseWaitRunnable infoTask = new PleaseWaitRunnable(tr("Connecting server")) { 79 80 @Override … … 95 96 msgLabel.addHyperlinkListener(hle -> { 96 97 if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) { 98 Logging.info(hle.getURL().toString()); 97 99 if (hle.getURL() == null || hle.getURL().toString().isEmpty()) { 98 100 return; 99 101 } 100 System.out.println("URL: "+ hle.getURL());101 102 if (!hle.getURL().toString().startsWith("http")) { 102 m Ruian.performAction(hle.getURL().toString());103 module.performAction(hle.getURL().toString()); 103 104 } else { 104 105 String ret = OpenBrowser.displayUrl(hle.getURL().toString()); … … 132 133 progressMonitor.beginTask(null, 3); 133 134 try { 134 m Ruian.prepareData(pos);135 htmlText = m Ruian.getHtml();135 module.prepareData(pos); 136 htmlText = module.getHtml(); 136 137 coordinatesText = PointInfoUtils.formatCoordinates(pos.lat(), pos.lon()); 137 138 -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoPlugin.java
r33549 r34168 2 2 package org.openstreetmap.josm.plugins.pointinfo; 3 3 4 import java.io.IOException; 5 import java.util.ArrayList; 6 import java.util.HashMap; 7 import java.util.Iterator; 8 import java.util.List; 9 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.coor.LatLon; 12 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 4 13 import org.openstreetmap.josm.gui.MainApplication; 5 14 import org.openstreetmap.josm.gui.MainMenu; 6 15 import org.openstreetmap.josm.plugins.Plugin; 7 16 import org.openstreetmap.josm.plugins.PluginInformation; 17 import org.openstreetmap.josm.plugins.pointinfo.ruian.RuianModule; 18 import org.openstreetmap.josm.plugins.pointinfo.catastro.CatastroModule; 8 19 9 20 /** … … 12 23 */ 13 24 public 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 } 14 31 15 32 /** … … 21 38 MainMenu.add(MainApplication.getMenu().moreToolsMenu, new PointInfoAction()); 22 39 } 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 } 23 90 } -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/PointInfoUtils.java
r32848 r34168 38 38 /** 39 39 * Return text representation of coordinates. 40 # @param lat Lat coordinate41 # @param lon Lon coordinate40 * @param lat the lat part of coordinates 41 * @param lon the lon part of coordinates 42 42 * @return String coordinatesText 43 43 */ -
applications/editors/josm/plugins/pointInfo/src/org/openstreetmap/josm/plugins/pointinfo/ruian/RuianModule.java
r33549 r34168 8 8 import org.openstreetmap.josm.tools.Logging; 9 9 10 import org.openstreetmap.josm.plugins.pointinfo.AbstractPointInfoModule; 11 10 12 /** 11 13 * A module for the Czech RUIAN database 12 14 * @author Marián Kyral 13 15 */ 14 public class RuianModule {16 public class RuianModule extends AbstractPointInfoModule { 15 17 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"; 17 21 18 22 private RuianRecord m_record = new RuianRecord(); … … 22 26 } 23 27 24 /** 25 * Return Html text representation 26 * @return String htmlText 27 */ 28 @Override 28 29 public String getHtml() { 29 30 return m_record.getHtml(); 30 31 } 31 32 32 /** 33 * Perform given action 34 * e.g.: copy tags to clipboard 35 * @param act Action to be performed 36 */ 33 @Override 37 34 public void performAction(String act) { 38 35 m_record.performAction(act); … … 43 40 * @param pos Position on the map 44 41 */ 42 @Override 45 43 public void prepareData(LatLon pos) { 46 44 try { … … 51 49 } 52 50 } 51 52 @Override 53 public String getName() { 54 return moduleName; 55 } 56 57 @Override 58 public String getArea() { 59 return areaName; 60 } 53 61 }
Note:
See TracChangeset
for help on using the changeset viewer.