Changeset 20931 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2010-04-18T23:40:01+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Buildings.java
r20659 r20931 55 55 public Point p; 56 56 public int dir; 57 @SuppressWarnings("unused") 58 public boolean toKeep; 57 59 public Pixel(int x, int y, int dir) { 58 60 this.p = new Point(x,y); … … 69 71 return p.equals(obj); 70 72 } 73 @Override 74 public String toString() { 75 return new String("p="+p+", dir="+dir); 76 } 71 77 } 72 78 private ArrayList<Pixel> listPixels = new ArrayList<Pixel>(); 73 79 74 private static final int cMaxnode = 10000; 75 private static final double cDistanceForOptimization = 0.7; 80 // 5 6 7 81 // \|/ 82 // 4-*-0 'dir' index vs pixel direction 83 // /|\ 84 // 3 2 1 76 85 private int[] dirsX = new int[] {1,1,0,-1,-1,-1,0,1}; 77 86 private int[] dirsY = new int[] {0,1,1,1,0,-1,-1,-1}; … … 80 89 BuildingsImageModifier bim = new BuildingsImageModifier(); 81 90 82 private double snapDistance = Main.pref.getDouble("cadastrewms.snap-distance", 50); // in centimeters 91 private static final int cMaxnode = 10000; 92 private static final double cDistanceForOptimization = 0.5; 93 private double snapDistance = Main.pref.getDouble("cadastrewms.snap-distance", 25); // in centimeters 94 private double SimplifyFactor = 0.1; 95 83 96 private double snapDistanceSq = snapDistance*snapDistance; 84 97 private double dx, dy; 85 86 98 87 99 public Buildings(MapFrame mapFrame) { … … 154 166 } 155 167 wayToCreate.addNode(wayToCreate.getNode(0)); // close the way 156 new SimplifyWay().simplifyWay(wayToCreate, 0.2);168 new SimplifyWay().simplifyWay(wayToCreate, SimplifyFactor); 157 169 // move the node closing the loop and simplify again 158 170 for (int i = 1; i < wayToCreate.getNodesCount(); i++) { … … 160 172 } 161 173 way2.addNode(way2.getNode(0)); 162 new SimplifyWay().simplifyWay(way2, 0.2);174 new SimplifyWay().simplifyWay(way2, SimplifyFactor); 163 175 simplifyAngles(way2); 164 176 Way wayToAdd = new Way(); … … 315 327 addPixeltoList(x, y, new_dir); 316 328 } 329 inflate(); 317 330 System.out.println("list size="+listPixels.size()); 318 331 return true; … … 322 335 listPixels.add( new Pixel(x, y, dir)); 323 336 System.out.println("added pixel at "+x+","+y); 337 } 338 339 private void inflate() { 340 // TODO 341 if (listPixels.size() > 1) { 342 // for (int i=1; i<listPixels.size()-1; i++) { 343 // int delta_dir = Math.abs((listPixels.get(i+1).dir - listPixels.get(i-1).dir + 8)%8); 344 // if (delta_dir > 1 && delta_dir < 4) { 345 // System.out.println(listPixels.get(i).dir); 346 // int j = i; 347 // if (listPixels.get(i).dir == 0 || listPixels.get(i).dir == 1 || listPixels.get(i).dir == 4 || listPixels.get(i).dir == 2) 348 // j = i-1; 349 // listPixels.get(j).toKeep = true; 350 // i+=2; 351 // selectedImage.image.setRGB(listPixels.get(j).p.x, listPixels.get(j).p.y, Color.GREEN.getRGB()); 352 // } 353 // } 354 ArrayList<Pixel> newList = new ArrayList<Pixel>(); 355 for (int i=0; i<listPixels.size(); i++) { 356 // selectedImage.image.setRGB(listPixels.get(i).p.x, listPixels.get(i).p.y, Color.GREEN.getRGB()); 357 boolean inflatedPixel = false; 358 for (int j=0; j<3; j++) { 359 if ((i+j-1) > 0 && (i+j-1) < listPixels.size()) { 360 int inflate_dir = (listPixels.get(i+j-1).dir+6)%8; 361 Pixel p = new Pixel(listPixels.get(i).p.x+dirsX[inflate_dir], 362 listPixels.get(i).p.y+dirsY[inflate_dir], 363 listPixels.get(i).dir); 364 if (bim.isParcelColor(selectedImage.image, p.p.x, p.p.y)) { 365 if (!newList.contains(p)) 366 newList.add(p); 367 inflatedPixel = true; 368 } 369 } 370 } 371 if (!inflatedPixel) { 372 if (!newList.contains(listPixels.get(i))) 373 newList.add(listPixels.get(i)); 374 } 375 } 376 listPixels = newList; 377 } 324 378 } 325 379 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r20824 r20931 94 94 public boolean loadCacheIfExist() { 95 95 try { 96 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension()); 97 if (file.exists()) { 98 JOptionPane pane = new JOptionPane( 99 tr("Location \"{0}\" found in cache.\n"+ 100 "Load cache first ?\n"+ 101 "(No = new cache)", wmsLayer.getName()), 102 JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null); 103 // this below is a temporary workaround to fix the "always on top" issue 104 JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille")); 105 CadastrePlugin.prepareDialog(dialog); 106 dialog.setVisible(true); 107 int reply = (Integer)pane.getValue(); 108 // till here 109 110 if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) { 111 return true; 112 } else { 113 delete(file); 96 if (!wmsLayer.isBuildingsOnly()) { 97 File file = new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "." + WMSFileExtension()); 98 if (file.exists()) { 99 JOptionPane pane = new JOptionPane( 100 tr("Location \"{0}\" found in cache.\n"+ 101 "Load cache first ?\n"+ 102 "(No = new cache)", wmsLayer.getName()), 103 JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null); 104 // this below is a temporary workaround to fix the "always on top" issue 105 JDialog dialog = pane.createDialog(Main.parent, tr("Select Feuille")); 106 CadastrePlugin.prepareDialog(dialog); 107 dialog.setVisible(true); 108 int reply = (Integer)pane.getValue(); 109 // till here 110 111 if (reply == JOptionPane.OK_OPTION && loadCache(file, wmsLayer.getLambertZone())) { 112 return true; 113 } else { 114 delete(file); 115 } 114 116 } 117 } else { 118 int i=0; 119 while (new File(CadastrePlugin.cacheDir + wmsLayer.getName() + "."+i+"."+ WMSFileExtension()).exists()) 120 i++; 121 wmsLayer.setName(wmsLayer.getName()+"."+i); 115 122 } 116 123 } catch (Exception e) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java
r20390 r20931 132 132 } 133 133 134 public boolean isParcelColor(BufferedImage img, int x, int y) { 135 int rgb = img.getRGB(x, y); 136 return (rgb == parcelColor); 137 } 138 134 139 public boolean isBuildingOrRoofColor(BufferedImage img, int x, int y, boolean ignoreParcelColor) { 135 140 int rgb = img.getRGB(x, y); … … 147 152 return ret; 148 153 } 149 154 150 155 /** 151 156 * Checks if the rgb value is the black background color
Note:
See TracChangeset
for help on using the changeset viewer.