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

Edigeo: support QAL file

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

Legend:

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

    r33646 r33647  
    5656        }
    5757
    58         protected void safeGet(EdigeoRecord r, List<String> list) {
     58        protected final void safeGet(EdigeoRecord r, List<String> list) {
    5959            list.add("");
    6060            safeGet(r, s -> {
     
    6464        }
    6565
    66         protected void safeGet(EdigeoRecord r, Consumer<String> callback) {
     66        protected final void safeGet(EdigeoRecord r, Consumer<String> callback) {
    6767            (lastReadString = callback).accept(r.length > 0 ? r.values.get(0) : null);
    6868        }
    6969
    70         protected int safeGetInt(EdigeoRecord r) {
     70        protected final int safeGetInt(EdigeoRecord r) {
    7171            return r.length > 0 ? Integer.parseInt(r.values.get(0)) : 0;
    7272        }
    7373
    74         protected LocalDate safeGetDate(EdigeoRecord r) {
     74        protected final LocalDate safeGetDate(EdigeoRecord r) {
    7575            return r.length > 0 ? LocalDate.parse(r.values.get(0), dateFormatter) : null;
    7676        }
    7777
    78         protected void safeGetAndLog(EdigeoRecord r, Consumer<String> callback, String msg) {
     78        protected final double safeGetDouble(EdigeoRecord r) {
     79            return r.length > 0 ? Double.parseDouble(r.values.get(0)) : 0;
     80        }
     81
     82        protected final void safeGetAndLog(EdigeoRecord r, Consumer<String> callback, String msg) {
    7983            if (r.length > 0) {
    8084                String v = r.values.get(0);
     
    8488        }
    8589
    86         protected LocalDate safeGetDateAndLog(EdigeoRecord r, String msg) {
     90        protected final LocalDate safeGetDateAndLog(EdigeoRecord r, String msg) {
    8791            if (r.length > 0) {
    8892                LocalDate v = LocalDate.parse(r.values.get(0), dateFormatter);
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileQAL.java

    r33643 r33647  
    44import java.io.IOException;
    55import java.nio.file.Path;
     6import java.time.LocalDate;
     7import java.util.ArrayList;
     8import java.util.List;
    69
    710/**
     
    912 */
    1013public class EdigeoFileQAL extends EdigeoFile {
     14
     15    /**
     16     * Update descriptor.
     17     */
     18    public static class Update extends Block {
     19
     20        enum UpdateType {
     21            NO_MODIFICATION(0),
     22            CREATION(1),
     23            REPLACEMENT(2),
     24            DELETION(3);
     25
     26            final int code;
     27            UpdateType(int code) {
     28                this.code = code;
     29            }
     30
     31            public static UpdateType of(int code) {
     32                for (UpdateType s : values()) {
     33                    if (s.code == code) {
     34                        return s;
     35                    }
     36                }
     37                throw new IllegalArgumentException(Integer.toString(code));
     38            }
     39        }
     40
     41        enum Perennity {
     42            TEMPORARY(1),
     43            DEFINITIVE(2);
     44
     45            final int code;
     46            Perennity(int code) {
     47                this.code = code;
     48            }
     49
     50            public static Perennity of(int code) {
     51                for (Perennity s : values()) {
     52                    if (s.code == code) {
     53                        return s;
     54                    }
     55                }
     56                throw new IllegalArgumentException(Integer.toString(code));
     57            }
     58        }
     59
     60        /** ODA */ LocalDate observationDate;
     61        /** UTY */ UpdateType updateType;
     62        /** ULO */ Perennity perennity;
     63        /** UDA */ LocalDate updateDate;
     64        /** RAT */ double annualRatio;
     65        /** EDA */ LocalDate endOfValidity;
     66        /** COC */ int nElements;
     67        /** COP */ final List<String> mcdRef = new ArrayList<>();
     68
     69        Update(String type) {
     70            super(type);
     71        }
     72
     73        @Override
     74        void processRecord(EdigeoRecord r) {
     75            switch (r.name) {
     76            case "ODA": observationDate = safeGetDate(r); break;
     77            case "UTY": updateType = UpdateType.of(safeGetInt(r)); break;
     78            case "ULO": perennity = Perennity.of(safeGetInt(r)); break;
     79            case "UDA": updateDate = safeGetDate(r); break;
     80            case "RAT": annualRatio = safeGetDouble(r); break;
     81            case "EDA": endOfValidity = safeGetDate(r); break;
     82            case "COC": nElements = safeGetInt(r); break;
     83            case "COP": safeGet(r, mcdRef); break;
     84            default:
     85                super.processRecord(r);
     86            }
     87        }
     88    }
    1189
    1290    /**
     
    2199    @Override
    22100    protected Block createBlock(String type) {
    23         // TODO Auto-generated method stub
    24         return null;
     101        if ("QUP".equals(type)) {
     102            return new Update(type);
     103        }
     104        throw new IllegalArgumentException(type);
    25105    }
    26 
    27106}
  • applications/editors/josm/plugins/cadastre-fr/src/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoFileSCD.java

    r33646 r33647  
    8484            FACE("FAC");
    8585
    86             String code;
     86            final String code;
    8787            PrimitiveKind(String code) {
    8888                this.code = code;
     
    189189            BELONG_TO("BET");
    190190
    191             String code;
     191            final String code;
    192192            RelationKind(String code) {
    193193                this.code = code;
Note: See TracChangeset for help on using the changeset viewer.