Ignore:
Timestamp:
2014-02-17T14:27:01+01:00 (11 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed2/src/s57
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/s57/S57att.java

    r30269 r30285  
     1/* Copyright 2014 Malcolm Herring
     2 *
     3 * This is free software: you can redistribute it and/or modify
     4 * it under the terms of the GNU General Public License as published by
     5 * the Free Software Foundation, version 3 of the License.
     6 *
     7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
     8 */
     9
    110package s57;
    211
  • applications/editors/josm/plugins/smed2/src/s57/S57dat.java

    r30284 r30285  
     1/* Copyright 2014 Malcolm Herring
     2 *
     3 * This is free software: you can redistribute it and/or modify
     4 * it under the terms of the GNU General Public License as published by
     5 * the Free Software Foundation, version 3 of the License.
     6 *
     7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
     8 */
     9
    110package s57;
    211
     12import java.io.UnsupportedEncodingException;
    313import java.util.ArrayList;
    414import java.util.Arrays;
     
    165175        private static int index;
    166176        private static S57field field;
     177        private static String aall = "US-ASCII";
     178        private static String nall = "US-ASCII";
    167179        public static int rnum;
    168180       
     
    219231                if (conv.bin == 0) {
    220232                        String str = "";
     233                        int i = 0;
    221234                        if (conv.asc == 0) {
    222                                 while (buffer[offset] != 0x1f) {
    223                                         str += (char)(buffer[offset++]);
    224                                 }
    225                                 offset++;
     235                                for (i=0; buffer[offset+i] != 0x1f; i++) {}
     236                                try {
     237                                        String charset = "";
     238                                        if (field == S57field.ATTF) charset = aall;
     239                                        else if (field == S57field.NATF) charset = nall;
     240                                        else charset = "US-ASCII";
     241                                        str = new String(buffer, offset, i, charset);
     242                                } catch (UnsupportedEncodingException e) {
     243                                        e.printStackTrace();
     244                                }
     245                                offset += i + 1;
    226246                        } else {
    227247                                str = new String(buffer, offset, conv.asc);
     
    239259                                }
    240260                                offset += Math.abs(conv.bin);
     261                                if ((subf == S57subf.AALL) || (subf == S57subf.NALL)) {
     262                                        String charset = "";
     263                                        switch ((int)val) {
     264                                        case 0:
     265                                                charset = "US-ASCII";
     266                                                break;
     267                                        case 1:
     268                                                charset = "ISO-8859-1";
     269                                                break;
     270                                        case 2:
     271                                                charset = "UTF-16LE";
     272                                                break;
     273                                        }
     274                                        if (subf == S57subf.NALL) {
     275                                                nall = charset;
     276                                        } else {
     277                                                aall = charset;
     278                                        }
     279                                }
    241280                                return val;
    242281                        } else {
  • applications/editors/josm/plugins/smed2/src/s57/S57dec.java

    r30284 r30285  
    1 /* Copyright 2013 Malcolm Herring
     1/* Copyright 2014 Malcolm Herring
    22 *
    33 * This is free software: you can redistribute it and/or modify
     
    6565                                                }
    6666                                                break;
     67                                        case DSSI:
     68                                                S57dat.getSubf(record, fields + pos, S57field.DSSI, S57subf.AALL);
     69                                                S57dat.getSubf(S57subf.NALL);
     70                                                break;
    6771                                        case DSPM:
    6872                                                comf = (double) (Long) S57dat.getSubf(record, fields + pos, S57field.DSPM, S57subf.COMF);
  • applications/editors/josm/plugins/smed2/src/s57/S57map.java

    r30284 r30285  
    1 /* Copyright 2013 Malcolm Herring
     1/* Copyright 2014 Malcolm Herring
    22 *
    33 * This is free software: you can redistribute it and/or modify
     
    9393       
    9494        public enum Rflag {
    95                 UNKN, AGGR, MASTER, SLAVE
     95                UNKN, MASTER, SLAVE
    9696        }
    9797       
     
    120120                public ObjMap() {
    121121                        super(Obj.class);
    122                 }
    123         }
    124 
    125         public class Aggr {
    126                 public RelTab rels;
    127                 public long par;
    128                 public Aggr() {
    129                         rels = new RelTab();
    130                         par = 0;
    131122                }
    132123        }
     
    218209                public Obj type;                        // Feature type
    219210                public AttMap atts;             // Feature attributes
    220                 public Aggr aggr;                       // Related objects
     211                public RelTab rels;             // Related objects
    221212                public ObjMap objs;             // Slave object attributes
    222213
     
    224215                        reln = Rflag.UNKN;
    225216                        geom = new Geom(Pflag.NOSP);
    226                         type = Obj.C_AGGR;
     217                        type = Obj.UNKOBJ;
    227218                        atts = new AttMap();
    228                         aggr = new Aggr();
     219                        rels = new RelTab();
    229220                        objs = new ObjMap();
    230221                }
     
    271262                        obj = Obj.BOYLAT;
    272263                if (obj == Obj.C_AGGR)
    273                         feature.reln = Rflag.AGGR;
     264                        feature.reln = Rflag.UNKN;
    274265                feature.geom = new Geom(p);
    275266                feature.type = obj;
     
    280271       
    281272        public void newObj(long id, int rind) {
    282                 Rflag r = Rflag.AGGR;
     273                Rflag r = Rflag.UNKN;
    283274                switch (rind) {
    284275                case 1:
     
    292283                        break;
    293284                }
    294                 feature.aggr.rels.add(new Reln(id, r));
     285                feature.rels.add(new Reln(id, r));
    295286        }
    296287       
     
    354345                for (long id : index.keySet()) {
    355346                        Feature feature = index.get(id);
    356                         for (Reln reln : feature.aggr.rels) {
     347                        for (Reln reln : feature.rels) {
    357348                                Feature rel = index.get(reln.id);
    358349                                if (cmpGeoms(feature.geom, rel.geom)) {
    359350                                        switch (reln.reln) {
    360                                         case MASTER:
    361                                                 feature.reln = Rflag.AGGR;
    362                                                 break;
    363351                                        case SLAVE:
    364352                                                feature.reln = Rflag.MASTER;
     
    388376                for (long id : index.keySet()) {
    389377                        Feature feature = index.get(id);
    390                         for (Reln reln : feature.aggr.rels) {
     378                        for (Reln reln : feature.rels) {
    391379                                Feature rel = index.get(reln.id);
    392380                                if (rel.reln == Rflag.SLAVE) {
     
    408396                nodes.put(id, node);
    409397                feature = new Feature();
    410                 feature.reln = Rflag.AGGR;
     398                feature.reln = Rflag.UNKN;
    411399                feature.geom.prim = Pflag.POINT;
    412400                feature.geom.elems.add(new Prim(id));
     
    416404        public void addEdge(long id) {
    417405                feature = new Feature();
    418                 feature.reln = Rflag.AGGR;
     406                feature.reln = Rflag.UNKN;
    419407                feature.geom.prim = Pflag.LINE;
    420408                feature.geom.elems.add(new Prim(id));
     
    436424        public void addArea(long id) {
    437425                feature = new Feature();
    438                 feature.reln = Rflag.AGGR;
     426                feature.reln = Rflag.UNKN;
    439427                feature.geom.prim = Pflag.AREA;
    440428                feature.geom.elems.add(new Prim(id));
     
    447435
    448436        public void addTag(String key, String val) {
     437                feature.reln = Rflag.MASTER;
    449438                String subkeys[] = key.split(":");
    450439                if ((subkeys.length > 1) && subkeys[0].equals("seamark")) {
     
    461450                                        att = S57att.enumAttribute(subkeys[2], obj);
    462451                                }
    463                                 ObjTab items = feature.objs.get(obj);
    464                                 if (items == null) {
    465                                         items = new ObjTab();
    466                                         feature.objs.put(obj, items);
    467                                         Feature type = new Feature();
    468                                         type.reln = Rflag.SLAVE;
    469                                         type.type = obj;
    470                                         type.geom = feature.geom;
    471                                 }
    472 //                              AttMap atts = items.get(idx);
    473 //                              if (atts == null) {
    474 //                                      atts = new AttMap();
    475 //                                      items.put(idx, atts);
    476 //                              }
    477 //                              AttVal<?> attval = S57val.convertValue(val, att);
    478 //                              if (attval.val != null)
    479 //                                      atts.put(att, attval);
     452                                ObjTab objs = feature.objs.get(obj);
     453                                if (objs == null) {
     454                                        objs = new ObjTab();
     455                                        feature.objs.put(obj, objs);
     456                                }
     457                                AttMap atts = objs.get(idx);
     458                                if (atts == null) {
     459                                        atts = new AttMap();
     460                                        objs.put(idx, atts);
     461                                }
     462                                AttVal<?> attval = S57val.convertValue(val, att);
     463                                if (attval.val != null)
     464                                        atts.put(att, attval);
    480465                        } else {
    481466                                if (subkeys[1].equals("type")) {
    482467                                        obj = S57obj.enumType(val);
    483                                         if (feature.objs.get(feature.type) == null) {
    484                                                 feature.objs.put(feature.type, new ObjTab());
    485                                                 Feature type = new Feature();
    486                                                 type.reln = Rflag.MASTER;
    487                                                 type.type = obj;
    488                                                 type.geom = feature.geom;
     468                                        feature.type = obj;
     469                                        ObjTab objs = feature.objs.get(obj);
     470                                        if (objs == null) {
     471                                                objs = new ObjTab();
     472                                                feature.objs.put(obj, objs);
     473                                        }
     474                                        AttMap atts = objs.get(0);
     475                                        if (atts == null) {
     476                                                atts = new AttMap();
     477                                                objs.put(0, atts);
    489478                                        }
    490479                                } else {
  • applications/editors/josm/plugins/smed2/src/s57/S57obj.java

    r30283 r30285  
     1/* Copyright 2014 Malcolm Herring
     2 *
     3 * This is free software: you can redistribute it and/or modify
     4 * it under the terms of the GNU General Public License as published by
     5 * the Free Software Foundation, version 3 of the License.
     6 *
     7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
     8 */
     9
    110package s57;
    211
  • applications/editors/josm/plugins/smed2/src/s57/S57val.java

    r30231 r30285  
     1/* Copyright 2014 Malcolm Herring
     2 *
     3 * This is free software: you can redistribute it and/or modify
     4 * it under the terms of the GNU General Public License as published by
     5 * the Free Software Foundation, version 3 of the License.
     6 *
     7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
     8 */
     9
    110package s57;
    211
Note: See TracChangeset for help on using the changeset viewer.