Changeset 6566 in josm


Ignore:
Timestamp:
2013-12-30T10:17:44+01:00 (6 years ago)
Author:
simon04
Message:

fix #9494 - Advanced object info: add "Center of bounding box", and for ways "Centroid"

Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/TransformNodesCommand.java

    r6173 r6566  
    128128     * Get the center of the nodes under modification.
    129129     * It's just the barycenter.
     130     * @see {@link org.openstreetmap.josm.tools.Geometry#getCentroid(java.util.List)}
    130131     */
    131132    public EastNorth getNodesCenter() {
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r6500 r6566  
    1414import java.text.DecimalFormat;
    1515import java.text.NumberFormat;
     16import java.util.Arrays;
    1617import java.util.Locale;
    1718
    1819import org.openstreetmap.josm.Main;
    1920import org.openstreetmap.josm.data.Bounds;
     21import org.openstreetmap.josm.tools.Utils;
    2022
    2123/**
     
    314316    }
    315317
     318    /**
     319     * Returns this lat/lon pair in human-readable format separated by {@code separator}.
     320     * @return String in the format {@code "1.23456[separator]2.34567"}
     321     */
     322    public String toStringCSV(String separator) {
     323        return Utils.join(separator, Arrays.asList(
     324                latToString(CoordinateFormat.DECIMAL_DEGREES),
     325                lonToString(CoordinateFormat.DECIMAL_DEGREES)
     326        ));
     327    }
     328
    316329    public LatLon interpolate(LatLon ll2, double proportion) {
    317330        return new LatLon(this.lat() + proportion * (ll2.lat() - this.lat()),
  • trunk/src/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialog.java

    r6406 r6566  
    4848import org.openstreetmap.josm.tools.DateUtils;
    4949import org.openstreetmap.josm.tools.GBC;
     50import org.openstreetmap.josm.tools.Geometry;
    5051import org.openstreetmap.josm.tools.WindowGeometry;
    5152
     
    241242            } else if (o instanceof Way) {
    242243                addBbox(o);
     244                add(tr("Centroid: "), Main.getProjection().eastNorth2latlon(
     245                        Geometry.getCentroid(((Way) o).getNodes())).toStringCSV(", "));
    243246                addWayNodes((Way) o);
    244247            } else if (o instanceof Relation) {
     
    278281                        Double.toString(bottomRigth.east()), ", ",
    279282                        Double.toString(topLeft.north()));
     283                add(tr("Center of bounding box: "), bbox.getCenter().toStringCSV(", "));
    280284            }
    281285        }
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r6362 r6566  
    660660
    661661    /**
    662      * Compute the centroid of nodes
     662     * Compute the centroid/barycenter of nodes
    663663     * @param nodes Nodes for which the centroid is wanted
    664664     * @return the centroid of nodes
Note: See TracChangeset for help on using the changeset viewer.