Changeset 21806 in osm for applications


Ignore:
Timestamp:
2010-06-19T22:02:05+02:00 (14 years ago)
Author:
upliner
Message:

buildings_tools bugfixes

Location:
applications/editors/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java

    r21804 r21806  
    7373        private void updMetrics() {
    7474                meter = 2 * Math.PI / (Math.cos(Math.toRadians(eastNorth2latlon(en[0]).lat())) * eqlen);
    75                 reset();
     75                len = 0;
    7676        }
    7777
     
    128128        public void setPlace(EastNorth p2, double width, double lenstep, boolean ignoreConstraints) {
    129129                if (en[0] == null)
    130                         en[0] = p2;
     130                        throw new IllegalStateException("setPlace() called without the base point");
    131131                this.heading = en[0].heading(p2);
    132132                double hdang = 0;
     
    153153
    154154        public void setPlaceRect(EastNorth p2) {
     155                if (en[0] == null)
     156                        throw new IllegalStateException("SetPlaceRect() called without the base point");
    155157                if (!isRectDrawing())
    156158                        throw new IllegalStateException("Invalid drawing mode");
     
    187189                DataSet ds = Main.main.getCurrentDataSet();
    188190                LatLon l = eastNorth2latlon(en);
    189                 List<Node> nodes = ds.searchNodes(new BBox(l.lon() - 0.00001, l.lat() - 0.00001,
    190                                 l.lon() + 0.00001, l.lat() + 0.00001));
     191                List<Node> nodes = ds.searchNodes(new BBox(l.lon() - 0.0000001, l.lat() - 0.0000001,
     192                                l.lon() + 0.0000001, l.lat() + 0.0000001));
     193                Node bestnode = null;
     194                double mindist = 0.0003;
    191195                for (Node n : nodes) {
    192                         if (OsmPrimitive.isUsablePredicate.evaluate(n))
    193                                 return n;
    194                 }
    195                 return null;
     196                        double dist = n.getCoor().distanceSq(l);
     197                        if (dist < mindist && OsmPrimitive.isUsablePredicate.evaluate(n)) {
     198                                bestnode = n;
     199                                mindist = dist;
     200                        }
     201                }
     202                return bestnode;
    196203        }
    197204
     
    202209                final Node[] nodes = new Node[4];
    203210                for (int i = 0; i < 4; i++) {
     211
    204212                        Node n = findNode(en[i]);
    205213                        if (n == null) {
     
    218226                Way w = new Way();
    219227                w.addNode(nodes[0]);
    220                 if (projection1(latlon2eastNorth(nodes[2].getCoor())) > 0) {
     228                if (projection1(en[2]) > 0) {
    221229                        w.addNode(nodes[1]);
    222230                        w.addNode(nodes[2]);
Note: See TracChangeset for help on using the changeset viewer.