Ignore:
Timestamp:
2017-09-22T02:58:54+02:00 (7 years ago)
Author:
donvip
Message:

Edigeo: unfortunate attempt to get bounds

Location:
applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileGEN.java

    r33649 r33651  
    77import java.nio.file.Path;
    88
     9import org.openstreetmap.josm.data.Bounds;
     10import org.openstreetmap.josm.data.coor.EastNorth;
    911import org.openstreetmap.josm.data.osm.DataSet;
     12import org.openstreetmap.josm.data.projection.Projection;
    1013import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileGEN.GenBlock;
    1114import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoFileTHF.ChildBlock;
     
    2730     */
    2831    public static class GeoBounds extends GenBlock {
    29         /** CM1 */ String min = "";
    30         /** CM2 */ String max = "";
     32        /** CM1 */ EastNorth min;
     33        /** CM2 */ EastNorth max;
    3134
    3235        GeoBounds(Lot lot, String type) {
     
    3740        void processRecord(EdigeoRecord r) {
    3841            switch (r.name) {
    39             case "CM1": safeGet(r, s -> min += s); break;
    40             case "CM2": safeGet(r, s -> max += s); break;
     42            case "CM1": min = safeGetEastNorth(r); break;
     43            case "CM2": max = safeGetEastNorth(r); break;
    4144            default:
    4245                super.processRecord(r);
     
    4851         * @return the minimal coordinates
    4952         */
    50         public final String getMinCm1() {
     53        public final EastNorth getMinCm1() {
    5154            return min;
    5255        }
     
    5659         * @return the maximal coordinates
    5760         */
    58         public final String getMaxCm2() {
     61        public final EastNorth getMaxCm2() {
    5962            return max;
     63        }
     64
     65        /**
     66         * Returns the bounds.
     67         * @return the bounds
     68         */
     69        public Bounds getBounds() {
     70/*
     71            for (String s : Projections.getAllProjectionCodes()) {
     72                Projection p = Projections.getProjectionByCode(s);
     73                LatLon en = p.eastNorth2latlon(min);
     74                double lat = en.lat();
     75                double lon = en.lon();
     76                if (43 <= lat && lat <= 44 && 1.38 <= lon && lon <= 1.45) {
     77                    System.out.println(s + ": " + p);
     78                }
     79            }
     80*/
     81            Projection proj = lot.geo.getCoorReference().getProjection();
     82            return new Bounds(proj.eastNorth2latlon(min), proj.eastNorth2latlon(max));
    6083        }
    6184    }
     
    154177        return this;
    155178    }
     179
     180    /**
     181     * Returns the geographic bounds.
     182     * @return the geographic bounds
     183     */
     184    public final GeoBounds getGeoBounds() {
     185        return blocks.getInstances(GeoBounds.class).get(0);
     186    }
    156187}
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileTHF.java

    r33649 r33651  
    444444        for (Lot lot : getLots()) {
    445445            lot.readFiles(path, ds);
     446            //ds.addDataSource(new DataSource(lot.gen.getGeoBounds().getBounds(), support.author));
    446447        }
    447448        return this;
Note: See TracChangeset for help on using the changeset viewer.