Changeset 15201 in osm for applications
- Timestamp:
- 2009-05-24T20:56:33+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/czechaddress
- Files:
-
- 5 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/czechaddress/build.xml
r15166 r15201 97 97 <pathelement path="${java.class.path}"/> 98 98 </classpath> 99 <arg value="/home/radek/Desktop/Hustopeče.osm"/> 99 100 </java> 100 101 </target> -
applications/editors/josm/plugins/czechaddress/nbproject/project.xml
r15166 r15201 5 5 <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1"> 6 6 <name>czechaddress</name> 7 <folders>8 <source-folder>9 <label>src</label>10 <type>java</type>11 <location>src</location>12 </source-folder>13 </folders>14 <ide-actions>15 <action name="build">16 <target>dist</target>17 </action>18 <action name="clean">19 <target>clean</target>20 </action>21 <action name="javadoc">22 <target>doc</target>23 </action>24 <action name="run">25 <target>run</target>26 </action>27 <action name="rebuild">28 <target>clean</target>29 <target>dist</target>30 </action>31 </ide-actions>32 <view>33 <items>34 <source-folder style="packages">35 <label>src</label>36 <location>src</location>37 </source-folder>38 </items>39 <context-menu>40 <ide-action name="build"/>41 <ide-action name="clean"/>42 <ide-action name="javadoc"/>43 <ide-action name="run"/>44 <ide-action name="rebuild"/>45 </context-menu>46 </view>47 <subprojects/>48 7 </general-data> 49 8 <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2"> … … 61 20 <type>java</type> 62 21 <location>src</location> 22 <encoding>UTF-8</encoding> 23 </source-folder> 24 <source-folder> 25 <label>tests</label> 26 <type>java</type> 27 <location>tests</location> 63 28 <encoding>UTF-8</encoding> 64 29 </source-folder> … … 86 51 </action> 87 52 </ide-actions> 88 <export>89 <type>folder</type>90 <location>dist</location>91 <build-target>compile</build-target>92 </export>93 53 <view> 94 54 <items> … … 96 56 <label>src</label> 97 57 <location>src</location> 58 </source-folder> 59 <source-folder style="packages"> 60 <label>tests</label> 61 <location>tests</location> 98 62 </source-folder> 99 63 <source-file> … … 115 79 <compilation-unit> 116 80 <package-root>src</package-root> 117 <classpath mode="compile">../../core/build:../../core/src </classpath>81 <classpath mode="compile">../../core/build:../../core/src:tests/junit-4.5.jar</classpath> 118 82 <javadoc-built-to>doc</javadoc-built-to> 83 <source-level>1.5</source-level> 84 </compilation-unit> 85 <compilation-unit> 86 <package-root>tests</package-root> 87 <unit-tests/> 119 88 <source-level>1.5</source-level> 120 89 </compilation-unit> -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java
r15166 r15201 24 24 import org.openstreetmap.josm.plugins.czechaddress.parser.MvcrParser; 25 25 import org.openstreetmap.josm.plugins.czechaddress.actions.FactoryAction; 26 import org.openstreetmap.josm.plugins.czechaddress.actions.HelpAction; 27 import org.openstreetmap.josm.plugins.czechaddress.actions.ModifierAction; 26 28 import org.openstreetmap.josm.plugins.czechaddress.actions.SplitAreaByEmptyWayAction; 27 29 import org.openstreetmap.josm.plugins.czechaddress.gui.FactoryDialog; … … 68 70 final MvcrParser parser = new MvcrParser(); 69 71 //parser.setFilter(null, null, null, ""); 70 //parser.setFilter("BRNO", "BRNO", null, null);72 parser.setFilter("HUSTOPEČE", "HUSTOPEČE", null, null); 71 73 parser.setTargetDatabase(mainDatabase); 72 74 parser.setStorageDir(pluginDir); … … 112 114 113 115 // Move houses from list of Houses to list of AddressElements. 114 List<House> tmp1 = location.getAllHouses(); 115 ArrayList<AddressElement> tmp2 = new ArrayList<AddressElement>(tmp1.size()); 116 for (House h : tmp1) tmp2.add(h); 116 List<House> houses = location.getAllHouses(); 117 ArrayList<AddressElement> pool 118 = new ArrayList<AddressElement>(houses.size()); 119 for (House house : houses) pool.add(house); 120 121 122 /*Capitalizator cap = new Capitalizator(Main.ds.allPrimitives(), 123 location.getStreets()); 124 for (Street s : cap.getClassifiedItems()) 125 System.out.println(s.toString() + " --> " + cap.translate(s).getName());*/ 117 126 118 127 // And add them to the reasoner. 119 mainReasoner = new Reasoner( tmp2);128 mainReasoner = new Reasoner(pool); 120 129 mainReasoner.addPrimitives(Main.ds.allPrimitives()); 121 130 } … … 186 195 menuItems.add(MainMenu.add(czechMenu, new GroupManipulatorAction())); 187 196 menuItems.add(MainMenu.add(czechMenu, new ConflictResolveAction())); 197 menuItems.add(MainMenu.add(czechMenu, new ModifierAction())); 198 menuItems.add(MainMenu.add(czechMenu, new HelpAction())); 188 199 return; 189 200 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StringUtils.java
r15166 r15201 1 1 package org.openstreetmap.josm.plugins.czechaddress; 2 3 import org.openstreetmap.josm.data.coor.LatLon; 2 4 3 5 /** … … 30 32 } 31 33 34 public static String coordinateToString(double coor) { 35 double degrees = Math.floor(coor); 36 double minutes = Math.floor( 60*(coor-degrees) ); 37 double seconds = 60*60*(coor-degrees-minutes/60); 38 39 return String.valueOf(Math.round( degrees)) + "°" + 40 String.valueOf(Math.round( minutes)) + "'" + 41 String.valueOf(Math.round(100*seconds)/100.0) + "\""; 42 } 43 44 public static String latLonToString(LatLon position) { 45 assert position != null; 46 //if (position == null) return ""; 47 48 return "(lat: " + coordinateToString(position.lat()) 49 + " lon: " + coordinateToString(position.lon()) + ")"; 50 } 51 52 /** 53 * String matcher with abbreviations 54 * 55 * <p>Returns {@code true} even if s1="Nám. Svobody" and 56 * s2="Náměstí Svobody".</p> 57 */ 58 public boolean matchAbbrev(String s1, String s2) { 59 String[] parts1 = s1.split(" +"); 60 String[] parts2 = s2.split(" +"); 61 62 if (parts1.length != parts2.length) 63 return false; 64 65 for (int i=0; i<parts1.length; i++) { 66 String part1 = parts1[i]; 67 String part2 = parts2[i]; 68 69 if (part1.charAt(part1.length()-1) == '.') 70 part1 = part1.substring(0, part1.length()-1); 71 72 if (part2.charAt(part2.length()-1) == '.') 73 part2 = part2.substring(0, part2.length()-1); 74 75 int minLen = Math.min(part1.length(), part2.length()); 76 part1 = part1.substring(0, minLen).toUpperCase(); 77 part2 = part2.substring(0, minLen).toUpperCase(); 78 79 if (!part1.equals(part2)) 80 return false; 81 } 82 return true; 83 } 84 32 85 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java
r15166 r15201 5 5 import org.openstreetmap.josm.data.osm.OsmPrimitive; 6 6 import org.openstreetmap.josm.data.osm.Way; 7 import org.openstreetmap.josm.plugins.czechaddress.StringUtils; 7 8 import org.openstreetmap.josm.plugins.czechaddress.intelligence.Match; 8 9 import org.openstreetmap.josm.plugins.czechaddress.proposal.Proposal; … … 275 276 276 277 return 0; // <-- just to make compilers happy. We cannot get here. 277 } 278 } 279 280 281 282 public String getIsIn() { 283 return getIsIn(null); 284 } 285 286 protected String getIsInName() { 287 return getName(); 288 } 289 290 private String getIsIn(String childString) { 291 292 String result = ""; 293 294 if (getIsInName() != null && !getIsInName().equals(childString)) { 295 result += getIsInName() + ", "; 296 } 297 298 if (parent != null) 299 result += parent.getIsIn(getIsInName()); 300 else 301 result += "CZ"; 302 303 return result; 304 } 278 305 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/House.java
r15166 r15201 171 171 pr.parentStreet.getName())); 172 172 173 if (pr.parentViToCi != null) {173 /* if (pr.parentViToCi != null) { 174 174 String targetIsIn = ""; 175 175 … … 188 188 prim.get(KEY_ADDR_CITY), 189 189 pr.parentViToCi.getName())); 190 190 */ 191 192 193 if (parent.parent != null) // For sure our parent is a ElemWithStreets 191 194 props.add(getStringFieldDiff(KEY_IS_IN, 192 195 prim.get(KEY_IS_IN), 193 targetIsIn));194 } 196 parent.parent.getIsIn())); 197 /* }*/ 195 198 196 199 // If we have added any proposal so far, add the source info as well. -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Region.java
r15166 r15201 95 95 return thisString; 96 96 } 97 98 @Override 99 protected String getIsInName() { 100 101 if (nuts3name != null) 102 return nuts3name + " kraj"; 103 104 if (nuts4name != null) 105 return nuts3name + " okres"; 106 107 return null; 108 } 97 109 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Street.java
r15166 r15201 1 1 package org.openstreetmap.josm.plugins.czechaddress.addressdatabase; 2 3 import org.openstreetmap.josm.data.osm.OsmPrimitive; 2 4 3 5 /** … … 24 26 } 25 27 26 27 28 /*int[] getFieldMatchList(OsmPrimitive primitive) { 28 @Override 29 protected int[] getFieldMatchList(OsmPrimitive primitive) { 29 30 int[] result = {0}; 30 31 … … 33 34 34 35 result[0] = matchField(name, primitive.get("name")); 35 36 37 if (primitive.get("name") != null) { 38 String[] parts1 = primitive.get("name").split("\\.* +"); 39 String[] parts2 = name.split("\\.* +"); 40 for (String p : parts1) 41 System.out.println("X: " + p); 42 for (String p : parts2) 43 System.out.println("Y: " + p); 44 } 45 36 46 return result; 37 } */47 } 38 48 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/StringUtils.java
r15166 r15201 14 14 public class StringUtils { 15 15 16 public static String coordinateToString(double coor) {17 double degrees = Math.floor(coor);18 double minutes = Math.floor( 60*(coor-degrees) );19 double seconds = 60*60*(coor-degrees-minutes/60);20 21 return String.valueOf(Math.round( degrees)) + "°" +22 String.valueOf(Math.round( minutes)) + "'" +23 String.valueOf(Math.round(100*seconds)/100.0) + "\"";24 }25 26 public static String latLonToString(LatLon position) {27 if (position == null) return "";28 29 return "(lat: " + coordinateToString(position.lat())30 + " lon: " + coordinateToString(position.lon()) + ")";31 }32 16 33 17 }
Note:
See TracChangeset
for help on using the changeset viewer.