Changeset 23190 in osm for applications/editors/josm/plugins/czechaddress
- Timestamp:
- 2010-09-15T18:54:18+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/CzechAddressPlugin.java
r22915 r23190 86 86 87 87 public CzechAddressPlugin(PluginInformation info) { 88 88 super(info); 89 89 90 90 /*boolean x; -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/DatabaseLoadException.java
r15166 r23190 6 6 /** 7 7 * Exception occuring during parsing the database. 8 * 8 * 9 9 * <p>This exception is used during <i>download</i>, <i>extraction</i> or 10 10 * <i>parsing</i> of the database. It can set a message to be displayed -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/NotNullList.java
r15585 r23190 6 6 /** 7 7 * ArrayList, which refuses to add {@code null}. 8 * 8 * 9 9 * @author Radomír Černoch, radomir.cernoch@gmail.com 10 10 */ … … 39 39 if (c == null) 40 40 return false; 41 41 42 42 if (c instanceof NotNullList) 43 43 return super.addAll(c); … … 46 46 return true; 47 47 } 48 48 49 49 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/PrimUtils.java
r16743 r23190 6 6 /** 7 7 * Utilities for handling {@link OsmPrimitive}s. 8 * 8 * 9 9 * @author Radomír Černoch, radomir.cernoch@gmail.com 10 10 */ -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StatusListener.java
r15585 r23190 21 21 * 22 22 * @see CzechAddressPlugin 23 * 23 * 24 24 * @author Radomír Černoch, radomir.cernoch@gmail.com 25 25 */ -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/StringUtils.java
r18894 r23190 107 107 return false; 108 108 } 109 109 110 110 return true; 111 111 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/ManagerAction.java
r15585 r23190 11 11 * 12 12 * @author Radomír Černoch, radomir.cernoch@gmail.com 13 * 13 * 14 14 * @see ManagerDialog 15 15 */ -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/actions/SplitAreaByEmptyWayAction.java
r21860 r23190 63 63 if (!(prim2 instanceof Way)) continue; 64 64 if (prim2.equals(prim)) continue; 65 65 Way border = (Way) prim2; 66 66 if (border.getNodes().size() == 0) continue; 67 67 if (border.keySet().size() > 0) continue; -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/AddressElement.java
r19943 r23190 14 14 * 15 15 * <p>Every element must have a <i>name</i> and may have a <i>parent</i>.</p> 16 * 16 * 17 17 * @author Radomír Černoch radomir.cernoch@gmail.com 18 18 */ … … 99 99 Node node = (Node) prim; 100 100 result += " " + StringUtils.latLonToString(node.getCoor()); 101 101 102 102 } else if (prim instanceof Way) { 103 103 Way way = (Way) prim; … … 135 135 /** 136 136 * Compares 2 elements. 137 * 137 * 138 138 * <p>Basic criterion to comparing elements is their <i>name</i> and the 139 139 * </i>parent</i>. Notice that this behaviour might be changed … … 217 217 } 218 218 219 219 220 220 protected int[] getFieldMatchList(OsmPrimitive primitive) { 221 int[] result = {0}; 221 int[] result = {0}; 222 222 return result; 223 223 } … … 242 242 */ 243 243 public int getQ(OsmPrimitive primitive) { 244 244 245 245 // Firstly get integers representing a match of every matchable field. 246 246 int[] fieldMatches = getFieldMatchList(primitive); 247 247 assert fieldMatches.length > 0; 248 248 249 249 // Now find the max and min of this array. 250 250 int minVal = fieldMatches[0]; … … 260 260 assert Math.abs(minVal) <= 1; 261 261 assert Math.abs(maxVal) <= 1; 262 262 263 263 // If the best among all fields is 'neutral' match, the given primitive 264 264 // has nothing to do with our field. 265 265 if (maxVal <= 0) 266 266 return Reasoner.MATCH_NOMATCH; 267 267 268 268 // If all fields are 1 --> ROCKSOLID MATCH 269 269 // If some are 1, none -1 --> PARTIAL MATCH … … 274 274 case +1 : return Reasoner.MATCH_ROCKSOLID; 275 275 } 276 276 277 277 return 0; // <-- just to make compilers happy. We cannot get here. 278 278 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Database.java
r15585 r23190 9 9 * <p>Contains the tree of all regions, municipalities, suburbs, streets 10 10 * and houses in the Czech republic.</p> 11 * 11 * 12 12 * @see AddressElement 13 13 * @see DatabaseParser -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithHouses.java
r15763 r23190 47 47 /** 48 48 * Returns all houses directly contained in this element. 49 * 49 * 50 50 * NOTICE: If a subclass element contains other data structured capable 51 51 * of storing houses, they are not included in the returned set. -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ElementWithStreets.java
r15585 r23190 24 24 public void addStreet(Street streetToAdd) { 25 25 //if (streetToAdd.getParent() instanceof ElementWithStreets) 26 26 27 27 streetToAdd.setParent(this); 28 28 streets.add(streetToAdd); … … 79 79 // We make an conservative estimate... 80 80 List<House> result = new ArrayList<House>(20 * streets.size()); 81 81 82 82 result.addAll(this.houses); 83 83 84 84 for (Street street : streets) 85 85 result.addAll(street.getHouses()); 86 86 87 87 return result; 88 88 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/House.java
r16743 r23190 20 20 * {@link ElementWithHouses}. The {@code setParent()} method should 21 21 * be called immediatelly after the constructor.</p> 22 * 22 * 23 23 * @author Radomír Černoch, radomir.cernoch@gmail.com 24 24 */ … … 44 44 45 45 assert (co != null) || (cp != null); 46 46 47 47 //... but the the name is overwritten. 48 48 this.name = generateName(this.cp, this.co); 49 49 } 50 50 51 51 /** 52 52 * Returns the number unique in a suburb (číslo popisné) … … 128 128 super.setParent(parent); 129 129 } 130 130 131 131 /** 132 132 * Returns the parent of this house with type-checking. … … 159 159 result[0] = matchField(this.cp, prim.get(PrimUtils.KEY_ADDR_CP)); 160 160 result[2] = matchField(name, prim.get(PrimUtils.KEY_ADDR_HOUSE_N)); 161 161 162 162 // Second field is the Housenumber 163 163 if (parent instanceof Street) … … 178 178 } 179 179 180 180 181 181 182 182 /** … … 188 188 @Override 189 189 public List<Proposal> getDiff(OsmPrimitive prim) { 190 190 191 191 List<Proposal> props = new NotNullList<Proposal>(); 192 192 ParentResolver resolver = new ParentResolver(this); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Region.java
r15585 r23190 10 10 */ 11 11 public class Region extends ElementWithStreets { 12 12 13 13 private ArrayList<ViToCi> vitocis 14 14 = new ArrayList<ViToCi>(); 15 15 16 16 /** 17 17 * Adds a single municipality into this element. … … 21 21 vitocis.add(municipality); 22 22 } 23 23 24 24 /** 25 25 * Replaces the list of municipalities of this element. … … 30 30 obec.setParent(this); 31 31 } 32 32 33 33 /** 34 34 * Returns the list of all municipalities in this region. … … 53 53 String nuts3name = null; 54 54 String nuts4name = null; 55 55 56 56 /** 57 57 * Default constructor setting the name of this region. … … 61 61 super(name); 62 62 } 63 63 64 64 /** 65 65 * Constructor which sets the region's name together with higher … … 71 71 if (nuts4name != null) this.nuts4name = nuts4name; 72 72 } 73 73 74 74 public String getNuts3Name() { 75 75 return nuts3name; 76 76 } 77 77 78 78 public String getNuts4Name() { 79 79 return nuts4name; 80 80 } 81 81 82 82 /** 83 83 * Returns the name of this region. If the NUTS3 name was entered, … … 86 86 @Override 87 87 public String toString() { 88 88 89 89 String thisString = name; 90 90 91 91 if (nuts3name != null) 92 92 thisString += " (kraj " + nuts3name + ")"; 93 93 94 94 return thisString; 95 95 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Street.java
r15582 r23190 25 25 super.setParent(parent); 26 26 } 27 27 28 28 @Override 29 29 public ElementWithStreets getParent() { … … 36 36 int[] result = {0}; 37 37 if (!isMatchable(primitive)) return result; 38 38 39 39 result[0] = matchFieldAbbrev(name, primitive.get("name")); 40 40 return result; … … 44 44 public List<Proposal> getDiff(OsmPrimitive prim) { 45 45 List<Proposal> props = new NotNullList<Proposal>(); 46 46 47 47 props.add(getStringFieldDiff(PrimUtils.KEY_NAME, prim.get(PrimUtils.KEY_NAME), getName())); 48 48 return props; -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/Suburb.java
r15582 r23190 6 6 /** 7 7 * Suburb is a part of a {@link Municipality}. 8 * 8 * 9 9 * @author Radomír Černoch radomir.cernoch@gmail.com 10 10 */ -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/addressdatabase/ViToCi.java
r15582 r23190 6 6 /** 7 7 * ViToCi is either a village, town or a city. 8 * 8 * 9 9 * @author Radomír Černoch radomir.cernoch@gmail.com 10 10 */ -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/ConflictResolver.java
r18408 r23190 234 234 if (r.translate(prim) != null) 235 235 r.unOverwrite(prim, r.translate(prim)); 236 236 237 237 ComboBoxModel model = candField.getModel(); 238 238 for (int i = 0; i < model.getSize(); i++) { … … 242 242 r.unOverwrite(r.translate(elem), elem); 243 243 } 244 244 245 245 r.doOverwrite(prim, (AddressElement) model.getSelectedItem()); 246 246 } … … 358 358 +AddressElement.getName(prim) + "“"); 359 359 primitives.add(-index-1, prim); 360 360 361 361 ListDataEvent evt = new ListDataEvent(this, 362 362 ListDataEvent.INTERVAL_ADDED, … … 364 364 for (ListDataListener listener : listeners) 365 365 listener.intervalAdded(evt); 366 366 367 367 if (mainField.getSelectedItem() == null) 368 368 mainField.setSelectedIndex(-index-1); … … 378 378 + elem.getName() + "“"); 379 379 elements.remove(index); 380 380 381 381 if (selected == elem) 382 382 setSelectedItem(null); … … 401 401 if (selected == prim) 402 402 setSelectedItem(null); 403 403 404 404 ListDataEvent evt = new ListDataEvent(this, 405 405 ListDataEvent.INTERVAL_REMOVED, … … 419 419 elements.clear(); 420 420 primitives.clear(); 421 421 422 422 for (ListDataListener listener : listeners) 423 423 listener.contentsChanged(evt); 424 424 } 425 425 426 426 public void setSelectedItem(Object anItem) { 427 427 … … 447 447 if (index< elements.size()) 448 448 return elements.get(index); 449 449 450 450 index -= elements.size(); 451 451 452 452 if (index< primitives.size()) 453 453 return primitives.get(index); 454 454 455 455 return null; 456 456 } … … 466 466 467 467 private void updateCandidatesModel(Object selected) { 468 468 469 469 if (selected instanceof AddressElement) { 470 470 AddressElement selElem = (AddressElement) selected; -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/FactoryDialog.java
r18896 r23190 52 52 private HouseListModel houseModel = new HouseListModel(); 53 53 private StreetListModel streetModel = new StreetListModel(); 54 54 55 55 private FactoryDialog() { 56 56 … … 89 89 return; 90 90 } 91 91 92 92 if (message == MESSAGE_LOCATION_CHANGED) { 93 93 DataSet.selListeners.add(this); … … 99 99 keepOddityCheckBox.setEnabled(true); 100 100 return; 101 } 101 } 102 102 } 103 103 … … 174 174 do { 175 175 selectNextUnmatchedHouse(); 176 176 177 177 String newStr = StringUtils.extractNumber(getSelectedHouse().getCO()); 178 178 … … 360 360 setFont(getFont().deriveFont(Font.PLAIN)); 361 361 setText(((Street) value).getName()); 362 362 363 363 } else if (value instanceof ElementWithHouses) { 364 364 setFont(getFont().deriveFont(Font.BOLD)); 365 365 setText("[" + ((ElementWithHouses) value).getName() + "]"); 366 366 } 367 367 368 368 return c; 369 369 } … … 435 435 House house = (House) elem; 436 436 int index = Collections.binarySearch(houses, house); 437 437 438 438 if (Reasoner.getInstance().translate(house) != null) { 439 439 if (index >= 0) houses.remove(index); … … 441 441 if (index < 0) houses.add(-index-1, house); 442 442 } 443 443 444 444 houseModel.notifyAllListeners(); 445 445 } … … 472 472 this.selected = parent; 473 473 this.parent = parent; 474 474 475 475 metaElem.set(0, parent); 476 476 metaElem.get(1).setHouses(parent.getAllHouses()); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/GroupManipulatorDialog.java
r22015 r23190 124 124 125 125 proposalTree.addKeyListener(new java.awt.event.KeyAdapter() { 126 126 @Override 127 127 public void keyReleased(java.awt.event.KeyEvent evt) { 128 128 proposalTreeKeyReleased(evt); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/LocationSelector.java
r22915 r23190 79 79 * 80 80 */ 81 81 private void initLocationHints() { 82 82 boolean assertions = false; 83 83 assert assertions = true; … … 177 177 int curHlIndex = 0; 178 178 179 for (int i = 0; i < list.getSize(); i++) 179 for (int i = 0; i < list.getSize(); i++) 180 180 for (int j = 0; j < hlList.size(); j++) { 181 181 Object t = list.getElementAt(i); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/PointManipulatorDialog.java
r22015 r23190 207 207 208 208 alternateNumberEdit.addKeyListener(new java.awt.event.KeyAdapter() { 209 209 @Override 210 210 public void keyReleased(java.awt.event.KeyEvent evt) { 211 211 PointManipulatorDialog.this.keyReleased(evt); … … 228 228 proposalList.addKeyListener(new java.awt.event.KeyAdapter() { 229 229 @Override 230 230 public void keyReleased(java.awt.event.KeyEvent evt) { 231 231 proposalListKeyReleased(evt); 232 232 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/databaseeditors/SuburbEditor.java
r18408 r23190 28 28 this.parent = suburb.getParent(); 29 29 nameField.setText(suburb.getName()); 30 30 31 31 if (parent != null) 32 32 parentField.setText(parent.getName()); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/utils/UniversalListRenderer.java
r15585 r23190 15 15 public Component getListCellRendererComponent(JList list, Object value, 16 16 int index, boolean isSelected, boolean cellHasFocus) { 17 17 18 18 Component c = super.getListCellRendererComponent(list, value, index, 19 19 isSelected, cellHasFocus); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/gui/utils/UniversalRenderer.java
r15585 r23190 34 34 35 35 public static ImageIcon getIcon(Object value) { 36 36 37 37 if (value instanceof AddKeyValueProposal) return iconAdd; 38 38 else if (value instanceof KeyValueChangeProposal) return iconEdit; … … 69 69 if (value instanceof AddressElement) 70 70 return ((AddressElement) value).getName(); 71 71 72 72 if (value instanceof OsmPrimitive) 73 73 return AddressElement.getName(value); … … 75 75 if (value == null) 76 76 return ""; 77 77 78 78 return value.toString(); 79 79 } -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/intelligence/Reasoner.java
r18896 r23190 99 99 * modify the data in the reasoner. 100 100 * The only exception is {@code reset()}.</p> 101 * 101 * 102 102 * <p>When there's an open transaction, the result of most output methods 103 103 * undefined. Exceptions to this rules are indicated.</p> … … 387 387 if (getStrictlyBest(elem) == prim) 388 388 return elem; 389 389 390 390 return null; 391 391 } … … 417 417 if (getStrictlyBest(prim) == elem) 418 418 return prim; 419 419 420 420 return null; 421 421 } … … 515 515 best = cand; 516 516 } 517 517 518 518 for (OsmPrimitive prim : elemMatchIndex.get(elem).keySet()) { 519 519 int cand = elemMatchIndex.get(elem).get(prim); … … 542 542 */ 543 543 public AddressElement getStrictlyBest(OsmPrimitive prim) { 544 544 545 545 AddressElement result = null; 546 546 try { … … 563 563 } 564 564 } 565 565 566 566 } catch (NullPointerException except) { 567 567 System.err.println("Strange exception occured." + … … 601 601 return null; 602 602 } 603 603 604 604 int bestQ = MATCH_NOMATCH; 605 605 for (OsmPrimitive prim : matches.keySet()) { … … 683 683 ProposalContainer container = new ProposalContainer(prim); 684 684 container.addProposals(elem.getDiff(prim)); 685 685 686 686 if (container.getProposals().size() > 0) 687 687 database.addContainer(container); -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/DatabaseParser.java
r19964 r23190 14 14 /** 15 15 * General superclass for any parser capable of filling the database. 16 * 16 * 17 17 * @see Database 18 18 * … … 43 43 /** 44 44 * The ultimate method, which starts filling the database. 45 * 45 * 46 46 * @throws DatabaseLoadException if anything goes wrong... 47 47 */ … … 60 60 /** 61 61 * The internal method, which does the actual parsing. 62 * 62 * 63 63 * @throws DatabaseLoadException should be thrown if anything gets wrong... 64 64 */ … … 87 87 * 88 88 * The URL is provided by {@code getDatabaseUrl()} method. 89 * 89 * 90 90 * @throws DatabaseLoadException if any error occurs during the download. 91 91 */ -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/parser/MvcrParser.java
r19964 r23190 57 57 return; 58 58 } 59 59 60 60 // ========== PARSING STREET ========== // 61 61 if (name.equals("ulice")) { … … 245 245 ZipEntry zipEntry = null; 246 246 try { 247 248 249 250 251 247 zis = new ZipInputStream(new FileInputStream(getDatabasePath())); 248 249 while ((zipEntry = zis.getNextEntry()) != null) 250 if (zipEntry.getName().equals("adresy.xml")) 251 break; 252 252 253 253 } catch (IOException ioexp) { … … 256 256 257 257 if (zipEntry == null) 258 258 throw new DatabaseLoadException( 259 259 "ZIP archiv s databází neobsahuje soubor 'adresy.xml'."); 260 260 -
applications/editors/josm/plugins/czechaddress/src/org/openstreetmap/josm/plugins/czechaddress/proposal/ProposalDatabase.java
r15166 r23190 85 85 public void addProposals(OsmPrimitive primitive, 86 86 Collection<Proposal> proposal) { 87 87 88 88 ProposalContainer container = findContainer(primitive); 89 89 if (container == null) { … … 114 114 /** 115 115 * Gives a reference to the internal list of {@link ProposalContainer}s. 116 * 116 * 117 117 * @return the refernence to internal changeset. 118 118 */
Note:
See TracChangeset
for help on using the changeset viewer.