Changeset 31955 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-01-06T09:33:48+01:00 (9 years ago)
Author:
malcolmh
Message:

[Seachart] update

Location:
applications/editors/josm/plugins/seachart
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachart/jicons/build.xml

    r31768 r31955  
    33  <property name="build" location="build"/>
    44  <property name="jarfile" location="./jicons.jar"/>
    5   <property name="ant.build.javac.target" value="1.7"/>
    6   <property name="ant.build.javac.source" value="1.7"/>
    75  <property name="batik.dir" value="/usr/local/bin/batik-1.7/"/>
    86  <path id="classpath">
  • applications/editors/josm/plugins/seachart/jrender/build.xml

    r31768 r31955  
    33  <property name="build" location="build"/>
    44  <property name="jarfile" location="./jrender.jar"/>
    5   <property name="ant.build.javac.target" value="1.7"/>
    6   <property name="ant.build.javac.source" value="1.7"/>
    75  <property name="batik.dir" value="/usr/local/bin/batik-1.7/"/>
    86  <path id="classpath">
  • applications/editors/josm/plugins/seachart/src/render/Signals.java

    r31722 r31955  
    283283        }
    284284
     285        class Sect {
     286    int dir;
     287    LitCHR chr;
     288    ColCOL col;
     289    ColCOL alt;
     290    String grp;
     291    double per;
     292    double rng;
     293        }
     294       
     295        @SuppressWarnings("unchecked")
    285296        public static void lights(Feature feature) {
    286 /*              Enum<ColCOL> col = null;
     297                Enum<ColCOL> col = null;
    287298                Enum<ColCOL> tcol = null;
    288299                ObjTab lights = feature.objs.get(Obj.LIGHTS);
     
    370381                        }
    371382                }
    372                 final Att matches[] = { Att.SIGPER, Att.SIGGRP, Att.MLTYLT, Att.LITCHR, Att.CATLIT, Att.HEIGHT };
    373                 ArrayList<ArrayList<AttMap>> groups = new ArrayList<ArrayList<AttMap>>();
    374                 for (AttMap sector : lights.values()) {
    375                         if (sector.containsKey(Att.COLOUR)) {
    376                                 boolean equal = false;
    377                                 for (ArrayList<AttMap> group : groups) {
    378                                         AttMap member = group.get(0);
    379                                         for (Att match : matches) {
    380                                                 if (!((sector.containsKey(match) && member.containsKey(match) && sector.get(match).val.equals(member.get(match).val)) || (!sector.containsKey(match) && !member.containsKey(match)))) {
    381                                                         equal = false;
    382                                                         break;
    383                                                 } else {
    384                                                         equal = true;
    385                                                 }
    386                                         }
    387                                         if (equal) {
    388                                                 group.add(sector);
    389                                                 break;
    390                                         }
    391                                 }
    392                                 if (!equal) {
    393                                         ArrayList<AttMap> group = new ArrayList<AttMap>();
    394                                         group.add(sector);
    395                                         groups.add(group);
    396                                 }
    397                         }
    398                 }
    399                 for (boolean sorted = false; !sorted;) {
    400                         sorted = true;
    401                         for (int i = 0; i < groups.size()-1; i ++) {
    402                                 if (groups.get(i).size() < groups.get(i+1).size()) {
    403                                         ArrayList<AttMap> tmp = groups.remove(i);
    404                                         groups.add(i+1, tmp);
    405                                         sorted = false;
    406                                 }
    407                         }
    408                 }
    409                 for (ArrayList<AttMap> group : groups) {
    410                         for (boolean sorted = false; !sorted;) {
    411                                 sorted = true;
    412                                 for (int i = 0; i < group.size()-1; i ++) {
    413                                         AttMap m0 = group.get(i);
    414                                         AttMap m1 = group.get(i+1);
    415                                         if (((m0.containsKey(Att.VALNMR) && m1.containsKey(Att.VALNMR) && ((int)(m0.get(Att.VALNMR).val) < (int)(m1.get(Att.VALNMR).val))))
    416                                                         || (!m0.containsKey(Att.VALNMR) && m1.containsKey(Att.VALNMR))) {
    417                                                 AttMap tmp = group.remove(i);
    418                                                 group.add(i+1, tmp);
    419                                                 sorted = false;
    420                                         }
    421                                 }
    422                         }
    423                 }
     383/*      int secmax = countObjects(item, "light");
     384      if ((idx == 0) && (secmax > 0)) {
     385        struct SECT {
     386          struct SECT *next;
     387          int dir;
     388          LitCHR_t chr;
     389          ColCOL_t col;
     390          ColCOL_t alt;
     391          char *grp;
     392          double per;
     393          double rng;
     394        } *lights = NULL;
     395        for (int i = secmax; i > 0; i--) {
     396          struct SECT *tmp = calloc(1, sizeof(struct SECT));
     397          tmp->next = lights;
     398          lights = tmp;
     399          obj = getObj(item, LIGHTS, i);
     400          if ((att = getAtt(obj, CATLIT)) != NULL) {
     401            lights->dir = testAtt(att, LIT_DIR);
     402          }
     403          if ((att = getAtt(obj, LITCHR)) != NULL) {
     404            lights->chr = att->val.val.e;
     405            switch (lights->chr) {
     406              case CHR_AL:
     407                lights->chr = CHR_F;
     408                break;
     409              case CHR_ALOC:
     410                lights->chr = CHR_OC;
     411                break;
     412              case CHR_ALLFL:
     413                lights->chr = CHR_LFL;
     414                break;
     415              case CHR_ALFL:
     416                lights->chr = CHR_FL;
     417                break;
     418              case CHR_ALFFL:
     419                lights->chr = CHR_FFL;
     420                break;
     421              default:
     422                break;
     423            }
     424          }
     425          if ((att = getAtt(obj, SIGGRP)) != NULL) {
     426            lights->grp = att->val.val.a;
     427          } else {
     428            lights->grp = "";
     429          }
     430          if ((att = getAtt(obj, SIGPER)) != NULL) {
     431            lights->per = att->val.val.f;
     432          }
     433          if ((att = getAtt(obj, VALNMR)) != NULL) {
     434            lights->rng = att->val.val.f;
     435          }
     436          if ((att = getAtt(obj, COLOUR)) != NULL) {
     437            lights->col = att->val.val.l->val;
     438            if (att->val.val.l->next != NULL)
     439              lights->alt = att->val.val.l->next->val;
     440          }
     441        }
     442        struct COLRNG {
     443          int col;
     444          double rng;
     445        } colrng[14];
     446        while (lights != NULL) {
     447          strcpy(string2, "");
     448          bzero(colrng, 14*sizeof(struct COLRNG));
     449          colrng[lights->col].col = 1;
     450          colrng[lights->col].rng = lights->rng;
     451          struct SECT *this = lights;
     452          struct SECT *next = lights->next;
     453          while (next != NULL) {
     454            if ((this->dir == next->dir) && (this->chr == next->chr) &&
     455                (strcmp(this->grp, next->grp) == 0) && (this->per == next->per)) {
     456              colrng[next->col].col = 1;
     457              if (next->rng > colrng[next->col].rng)
     458                colrng[next->col].rng = next->rng;
     459              struct SECT *tmp = lights;
     460              while (tmp->next != next) tmp = tmp->next;
     461              tmp->next = next->next;
     462              free(next);
     463              next = tmp->next;
     464            } else {
     465              next = next->next;
     466            }
     467          }
     468          if (this->chr != CHR_UNKN) {
     469            if (this->dir) strcpy(string2, "Dir.");
     470            strcat(string2, light_characters[this->chr]);
     471            if (strcmp(this->grp, "") != 0) {
     472              if (this->grp[0] == '(')
     473                sprintf(strchr(string2, 0), "%s", this->grp);
     474              else
     475                sprintf(strchr(string2, 0), "(%s)", this->grp);
     476            } else {
     477              if (strlen(string2) > 0) strcat(string2, ".");
     478            }
     479            int n = 0;
     480            for (int i = 0; i < 14; i++) if (colrng[i].col) n++;
     481            double max = 0.0;
     482            for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > max)) max = colrng[i].rng;
     483            double min = max;
     484            for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng > 0.0) && (colrng[i].rng < min)) min = colrng[i].rng;
     485            if (min == max) {
     486              for (int i = 0; i < 14; i++) if (colrng[i].col) strcat(string2, light_letters[i]);
     487            } else {
     488              for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng == max)) strcat(string2, light_letters[i]);
     489              for (int i = 0; i < 14; i++) if (colrng[i].col && (colrng[i].rng < max) && (colrng[i].rng > min)) strcat(string2, light_letters[i]);
     490              for (int i = 0; i < 14; i++) if (colrng[i].col && colrng[i].rng == min) strcat(string2, light_letters[i]);
     491            }
     492            strcat(string2, ".");
     493            if (this->per > 0.0) sprintf(strchr(string2, 0), "%gs", this->per);
     494            if (max > 0.0) {
     495              sprintf(strchr(string2, 0), "%g", max);
     496              if (min != max) {
     497                if (n == 2) strcat(string2, "/");
     498                else if (n > 2) strcat(string2, "-");
     499                if (min < max) sprintf(strchr(string2, 0), "%g", min);
     500              }
     501              strcat(string2, "M");
     502            }
     503            if (strlen(string1) > 0) strcat(string1, "\n");
     504            strcat(string1, string2);
     505          }
     506          lights = this->next;
     507          free(this);
     508          this = lights;
     509        }
     510      } else {
     511        if ((att = getAtt(obj, CATLIT)) != NULL) {
     512          if (testAtt(att, LIT_DIR))
     513            strcat(string1, "Dir");
     514        }
     515        if ((att = getAtt(obj, MLTYLT)) != NULL)
     516          sprintf(strchr(string1, 0), "%s", stringValue(att->val));
     517        if ((att = getAtt(obj, LITCHR)) != NULL) {
     518          char *chrstr = strdup(stringValue(att->val));
     519          Att_t *grp = getAtt(obj, SIGGRP);
     520          if (grp != NULL) {
     521            char *strgrp = strdup(stringValue(grp->val));
     522            char *grpstr = strtok(strgrp, "()");
     523            switch (att->val.val.e) {
     524              case CHR_QLFL:
     525                sprintf(strchr(string1, 0), "Q(%s)+LFl", grpstr);
     526                break;
     527              case CHR_VQLFL:
     528                sprintf(strchr(string1, 0), "VQ(%s)+LFl", grpstr);
     529                break;
     530              case CHR_UQLFL:
     531                sprintf(strchr(string1, 0), "UQ(%s)+LFl", grpstr);
     532                break;
     533              default:
     534                sprintf(strchr(string1, 0), "%s(%s)", chrstr, grpstr);
     535                break;
     536            }
     537            free(strgrp);
     538          } else {
     539            sprintf(strchr(string1, 0), "%s", chrstr);
     540          }
     541          free(chrstr);
     542        }
     543        if ((att = getAtt(obj, COLOUR)) != NULL) {
     544          int n = countValues(att);
     545          if (!((n == 1) && (idx == 0) && (testAtt(att, COL_WHT)))) {
     546            if ((strlen(string1) > 0) && ((string1[strlen(string1)-1] != ')')))
     547              strcat(string1, ".");
     548            Lst_t *lst = att->val.val.l;
     549            while (lst != NULL) {
     550              strcat(string1, light_letters[lst->val]);
     551              lst = lst->next;
     552            }
     553          }
     554        }
     555        if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
     556          if (testAtt(att, LIT_VERT))
     557            strcat(string1, "(vert)");
     558          if (testAtt(att, LIT_HORI))
     559            strcat(string1, "(hor)");
     560        }
     561        if ((strlen(string1) > 0) &&
     562            ((getAtt(obj, SIGPER) != NULL) ||
     563             (getAtt(obj, HEIGHT) != NULL) ||
     564             (getAtt(obj, VALMXR) != NULL)) &&
     565            (string1[strlen(string1)-1] != ')'))
     566          strcat(string1, ".");
     567        if ((att = getAtt(obj, SIGPER)) != NULL)
     568          sprintf(strchr(string1, 0), "%ss", stringValue(att->val));
     569        if ((idx == 0) && (item->objs.obj != LITMIN)) {
     570          if ((att = getAtt(obj, HEIGHT)) != NULL)
     571            sprintf(strchr(string1, 0), "%sm", stringValue(att->val));
     572          if ((att = getAtt(obj, VALNMR)) != NULL)
     573            sprintf(strchr(string1, 0), "%sM", stringValue(att->val));
     574        }
     575        if ((idx == 0) && (att = getAtt(obj, CATLIT)) != NULL) {
     576          if (testAtt(att, LIT_FRNT))
     577            strcat(string1, "(Front)");
     578          if (testAtt(att, LIT_REAR))
     579            strcat(string1, "(Rear)");
     580          if (testAtt(att, LIT_UPPR))
     581            strcat(string1, "(Upper)");
     582          if (testAtt(att, LIT_LOWR))
     583            strcat(string1, "(Lower)");
     584        }
     585      }
     586    }
    424587*/      }
    425588
  • applications/editors/josm/plugins/seachart/src/s57/S57att.java

    r31846 r31955  
    147147  AttStr.put(Att.UPDMSG, "message"); AttStr.put(Att.LITRAD, "radius");
    148148 }
    149  
    150149 private static final EnumMap<Obj, Att> Accuracy = new EnumMap<>(Obj.class); static { Accuracy.put(Obj.UNKOBJ, Att.HORACC); }
    151150 private static final EnumMap<Obj, Att> Addition = new EnumMap<>(Obj.class); static { Addition.put(Obj.UNKOBJ, Att.ADDMRK); }
     
    158157 private static final EnumMap<Obj, Att> Category = new EnumMap<>(Obj.class); static {
    159158  Category.put(Obj.ACHARE, Att.CATACH); Category.put(Obj.ACHBRT, Att.CATACH); Category.put(Obj.AIRARE, Att.CATAIR); Category.put(Obj.BCNCAR, Att.CATCAM); Category.put(Obj.BCNLAT, Att.CATLAM);
    160   Category.put(Obj.BCNSPP, Att.CATSPM); Category.put(Obj.BOYLAT, Att.CATLAM); Category.put(Obj.BOYINB, Att.CATINB); Category.put(Obj.BOYSPP, Att.CATSPM);
     159  Category.put(Obj.BCNSPP, Att.CATSPM); Category.put(Obj.BOYLAT, Att.CATLAM); Category.put(Obj.BOYINB, Att.CATINB); Category.put(Obj.BOYSPP, Att.CATSPM); Category.put(Obj.DAYMAR, Att.CATSPM);
    161160  Category.put(Obj.BRIDGE, Att.CATBRG); Category.put(Obj.BUAARE, Att.CATBUA); Category.put(Obj.BUNSTA, Att.CATBUN); Category.put(Obj.CANALS, Att.CATCAN);
    162161  Category.put(Obj.CBLARE, Att.CATCBL); Category.put(Obj.CBLOHD, Att.CATCBL); Category.put(Obj.CBLSUB, Att.CATCBL); Category.put(Obj.CHKPNT, Att.CATCHP); Category.put(Obj.COMARE, Att.CATCOM);
  • applications/editors/josm/plugins/seachart/src/s57/S57map.java

    r31846 r31955  
    559559       
    560560        // Utility methods
    561        
     561
    562562        public boolean sortGeom(Feature feature) {
    563                 Geom sort = new Geom(feature.geom.prim);
    564                 long first = 0;
    565                 long last = 0;
    566                 Comp comp = null;
    567                 boolean next = true;
    568                 feature.geom.length = 0;
    569                 feature.geom.area = 0;
    570                 if (feature.geom.elems.isEmpty()) {
    571                         return false;
    572                 }
    573                 if (feature.geom.prim == Pflag.POINT) {
    574                         feature.geom.centre = nodes.get(feature.geom.elems.get(0).id);
    575                         return true;
    576                 }       else {
    577                         int sweep = feature.geom.elems.size();
    578                         while (!feature.geom.elems.isEmpty()) {
    579                                 Prim prim = feature.geom.elems.remove(0);
    580                                 Edge edge = edges.get(prim.id);
    581                                 if (edge == null) {
    582                                         return false;
    583                                 }
    584                                 if (next == true) {
    585                                         next = false;
    586                                         first = edge.first;
    587                                         last = edge.last;
    588                                         prim.forward = true;
    589                                         sort.elems.add(prim);
    590                                         if (prim.outer) {
    591                                                 sort.outers++;
    592                                         } else {
    593                                                 sort.inners++;
    594                                         }
    595                                         comp = new Comp(cref++, 1);
    596                                         sort.comps.add(comp);
    597                                 } else {
    598                                         if (edge.first == last) {
    599                                                 sort.elems.add(prim);
     563                try {
     564                        Geom sort = new Geom(feature.geom.prim);
     565                        long first = 0;
     566                        long last = 0;
     567                        Comp comp = null;
     568                        boolean next = true;
     569                        feature.geom.length = 0;
     570                        feature.geom.area = 0;
     571                        if (feature.geom.elems.isEmpty()) {
     572                                return false;
     573                        }
     574                        if (feature.geom.prim == Pflag.POINT) {
     575                                feature.geom.centre = nodes.get(feature.geom.elems.get(0).id);
     576                                return true;
     577                        } else {
     578                                int sweep = feature.geom.elems.size();
     579                                while (!feature.geom.elems.isEmpty()) {
     580                                        Prim prim = feature.geom.elems.remove(0);
     581                                        Edge edge = edges.get(prim.id);
     582                                        if (edge == null) {
     583                                                return false;
     584                                        }
     585                                        if (next == true) {
     586                                                next = false;
     587                                                first = edge.first;
    600588                                                last = edge.last;
    601589                                                prim.forward = true;
    602                                                 comp.size++;
    603                                         } else if (edge.last == first) {
    604                                                 sort.elems.add(0, prim);
    605                                                 first = edge.first;
    606                                                 prim.forward = true;
    607                                                 comp.size++;
    608                                         } else if (edge.last == last) {
    609590                                                sort.elems.add(prim);
    610                                                 last = edge.first;
    611                                                 prim.forward = false;
    612                                                 comp.size++;
    613                                         } else if (edge.first == first) {
    614                                                 sort.elems.add(0, prim);
    615                                                 first = edge.last;
    616                                                 prim.forward = false;
    617                                                 comp.size++;
     591                                                if (prim.outer) {
     592                                                        sort.outers++;
     593                                                } else {
     594                                                        sort.inners++;
     595                                                }
     596                                                comp = new Comp(cref++, 1);
     597                                                sort.comps.add(comp);
    618598                                        } else {
    619                                                 feature.geom.elems.add(prim);
    620                                         }
    621                                 }
    622                                 if (--sweep == 0) {
    623                                         next = true;
    624                                         sweep = feature.geom.elems.size();
    625                                 }
    626                         }
    627                         if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) {
    628                                 sort.prim = Pflag.AREA;
    629                         }
    630                         feature.geom = sort;
    631                 }
    632                 if (feature.geom.prim == Pflag.AREA) {
    633                         int ie = 0;
    634                         int ic = 0;
    635                         while (ie < feature.geom.elems.size()) {
    636                                 double area = calcArea(feature.geom, ic);
    637                                 if (ie == 0) feature.geom.area = Math.abs(area) * 3444 * 3444;
    638                                 if (((ie == 0) && (area < 0.0)) || ((ie > 0) && (area >= 0.0))) {
    639                                         ArrayList<Prim> tmp = new ArrayList<>();
    640                                         for (int i = 0; i < feature.geom.comps.get(ic).size; i++) {
    641                                                 Prim p = feature.geom.elems.remove(ie);
    642                                                 p.forward = !p.forward;
    643                                                 tmp.add(0, p);
    644                                         }
    645                                         feature.geom.elems.addAll(ie, tmp);
    646                                 }
    647                                 ie += feature.geom.comps.get(ic).size;
    648                                 ic++;
    649                         }
    650                 }
    651                 feature.geom.length = calcLength(feature.geom);
    652                 feature.geom.centre = calcCentroid(feature);
    653                 return true;
     599                                                if (edge.first == last) {
     600                                                        sort.elems.add(prim);
     601                                                        last = edge.last;
     602                                                        prim.forward = true;
     603                                                        comp.size++;
     604                                                } else if (edge.last == first) {
     605                                                        sort.elems.add(0, prim);
     606                                                        first = edge.first;
     607                                                        prim.forward = true;
     608                                                        comp.size++;
     609                                                } else if (edge.last == last) {
     610                                                        sort.elems.add(prim);
     611                                                        last = edge.first;
     612                                                        prim.forward = false;
     613                                                        comp.size++;
     614                                                } else if (edge.first == first) {
     615                                                        sort.elems.add(0, prim);
     616                                                        first = edge.last;
     617                                                        prim.forward = false;
     618                                                        comp.size++;
     619                                                } else {
     620                                                        feature.geom.elems.add(prim);
     621                                                }
     622                                        }
     623                                        if (--sweep == 0) {
     624                                                next = true;
     625                                                sweep = feature.geom.elems.size();
     626                                        }
     627                                }
     628                                if ((sort.prim == Pflag.LINE) && (sort.outers == 1) && (sort.inners == 0) && (first == last)) {
     629                                        sort.prim = Pflag.AREA;
     630                                }
     631                                feature.geom = sort;
     632                        }
     633                        if (feature.geom.prim == Pflag.AREA) {
     634                                int ie = 0;
     635                                int ic = 0;
     636                                while (ie < feature.geom.elems.size()) {
     637                                        double area = calcArea(feature.geom, ic);
     638                                        if (ie == 0)
     639                                                feature.geom.area = Math.abs(area) * 3444 * 3444;
     640                                        if (((ie == 0) && (area < 0.0)) || ((ie > 0) && (area >= 0.0))) {
     641                                                ArrayList<Prim> tmp = new ArrayList<>();
     642                                                for (int i = 0; i < feature.geom.comps.get(ic).size; i++) {
     643                                                        Prim p = feature.geom.elems.remove(ie);
     644                                                        p.forward = !p.forward;
     645                                                        tmp.add(0, p);
     646                                                }
     647                                                feature.geom.elems.addAll(ie, tmp);
     648                                        }
     649                                        ie += feature.geom.comps.get(ic).size;
     650                                        ic++;
     651                                }
     652                        }
     653                        feature.geom.length = calcLength(feature.geom);
     654                        feature.geom.centre = calcCentroid(feature);
     655                        return true;
     656                } catch (Exception e) {
     657                        return false;
     658                }
    654659        }
    655660       
  • applications/editors/josm/plugins/seachart/src/s57/S57osm.java

    r31846 r31955  
    4747                OSMtags.put("landuse=industrial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=commercial", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
    4848                OSMtags.put("landuse=retail", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null)); OSMtags.put("landuse=residential", new KeyVal<>(Obj.BUAARE, Att.UNKATT, null, null));
    49         }
     49                OSMtags.put("place=city", new KeyVal<>(Obj.BUAARE, Att.CATBUA, Conv.E, CatBUA.BUA_CITY)); OSMtags.put("place=town", new KeyVal<>(Obj.BUAARE, Att.CATBUA, Conv.E, CatBUA.BUA_TOWN));
     50                OSMtags.put("place=village", new KeyVal<>(Obj.BUAARE, Att.CATBUA, Conv.E, CatBUA.BUA_VLLG));
     51                }
    5052       
    5153        public static KeyVal<?> OSMtag(String key, String val) {
     
    142144                                                                }
    143145                                                        }
    144                                                         map.addToEdge(ref);
     146                                                        try {
     147                                                                map.addToEdge(ref);
     148                                                        } catch (Exception e) {
     149                                                                inWay = false;
     150                                                        }
    145151                                                }
    146152                                                if (ln.contains("</way")) {
Note: See TracChangeset for help on using the changeset viewer.