Ignore:
Timestamp:
2015-02-19T21:52:40+01:00 (11 years ago)
Author:
malcolmh
Message:

add base map rendering

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachart/src/s57/S57map.java

    r31014 r31027  
    1818import s57.S57val;
    1919import s57.S57val.*;
     20import s57.S57osm;
     21import s57.S57osm.*;
    2022
    2123public class S57map {
     
    482484
    483485        public void tagsDone(long id) {
    484                 if (feature.type == Obj.UNKOBJ) {
    485                         for (OSMtag tag : osmtags) {
    486                                 Obj obj = S57obj.OSMobj(tag.key, tag.val);
    487                                 if (obj != Obj.UNKOBJ) {
    488                                         feature.type = obj;
    489                                         ObjTab objs = feature.objs.get(obj);
    490                                         if (objs == null) {
    491                                                 objs = new ObjTab();
    492                                                 feature.objs.put(obj, objs);
    493                                         }
    494                                         AttMap atts = objs.get(0);
    495                                         if (atts == null) {
    496                                                 atts = new AttMap();
    497                                                 objs.put(0, atts);
    498                                         }
    499                                         AttVal<?> attval = S57val.OSMatt(tag.key, tag.val);
    500                                         if (attval.att != Att.UNKATT) {
    501                                                 atts.put(attval.att, attval);
    502                                         }
    503                                         break;
    504                                 }
     486                for (OSMtag tag : osmtags) {
     487                        KeyVal kv = S57osm.OSMtag(tag.key, tag.val);
     488                        if (kv.obj != Obj.UNKOBJ) {
     489                                if (feature.type == Obj.UNKOBJ) {
     490                                        feature.type = kv.obj;
     491                                }
     492                                ObjTab objs = feature.objs.get(kv.obj);
     493                                if (objs == null) {
     494                                        objs = new ObjTab();
     495                                        feature.objs.put(kv.obj, objs);
     496                                }
     497                                AttMap atts = objs.get(0);
     498                                if (atts == null) {
     499                                        atts = new AttMap();
     500                                        objs.put(0, atts);
     501                                }
     502                                if (kv.att != Att.UNKATT) {
     503                                        atts.put(kv.att, new AttVal(kv.att, kv.conv, kv.val));
     504                                }
     505                                break;
    505506                        }
    506507                }
     
    594595                        nedge.last = first;
    595596                        switch (lext) {
    596                         case NE:
    597597                        case N:
    598                                 if ((fext != Ext.NE) && (fext != Ext.N)) {
     598                                if ((lext == fext) || (fext != Ext.N)) {
    599599                                        nedge.nodes.add(1L);
    600                                         if ((fext != Ext.NW) && (fext != Ext.W)) {
     600                                        if ((fext != Ext.W)) {
    601601                                                nedge.nodes.add(2L);
    602                                                 if ((fext != Ext.SW) && (fext != Ext.S)) {
     602                                                if ((fext != Ext.S)) {
    603603                                                        nedge.nodes.add(3L);
    604                                                         if ((fext != Ext.SE) && (fext != Ext.W)) {
     604                                                        if ((fext != Ext.W)) {
    605605                                                                nedge.nodes.add(4L);
    606606                                                        }
     
    609609                                }
    610610                                break;
    611                         case NW:
    612611                        case W:
    613                                 if ((fext != Ext.NW) && (fext != Ext.W)) {
     612                                if ((lext == fext) || (fext != Ext.W)) {
    614613                                        nedge.nodes.add(2L);
    615                                         if ((fext != Ext.SW) && (fext != Ext.S)) {
     614                                        if ((fext != Ext.S)) {
    616615                                                nedge.nodes.add(3L);
    617                                                 if ((fext != Ext.SE) && (fext != Ext.E)) {
     616                                                if ((fext != Ext.E)) {
    618617                                                        nedge.nodes.add(4L);
    619                                                         if ((fext != Ext.NE) && (fext != Ext.N)) {
     618                                                        if ( (fext != Ext.N)) {
    620619                                                                nedge.nodes.add(1L);
    621620                                                        }
     
    624623                                }
    625624                                break;
    626                         case SW:
    627625                        case S:
    628                                 if ((fext != Ext.SW) && (fext != Ext.S)) {
     626                                if ((lext == fext) || (fext != Ext.S)) {
    629627                                        nedge.nodes.add(3L);
    630                                         if ((fext != Ext.SE) && (fext != Ext.E)) {
     628                                        if ((fext != Ext.E)) {
    631629                                                nedge.nodes.add(4L);
    632                                                 if ((fext != Ext.NE) && (fext != Ext.N)) {
     630                                                if ((fext != Ext.N)) {
    633631                                                        nedge.nodes.add(1L);
    634                                                         if ((fext != Ext.NW) && (fext != Ext.W)) {
     632                                                        if ((fext != Ext.W)) {
    635633                                                                nedge.nodes.add(2L);
    636634                                                        }
     
    639637                                }
    640638                                break;
    641                         case SE:
    642639                        case E:
    643                                 if ((fext != Ext.SE) && (fext != Ext.E)) {
     640                                if ((lext == fext) || (fext != Ext.E)) {
    644641                                        nedge.nodes.add(4L);
    645                                         if ((fext != Ext.NE) && (fext != Ext.N)) {
     642                                        if ((fext != Ext.N)) {
    646643                                                nedge.nodes.add(1L);
    647                                                 if ((fext != Ext.NW) && (fext != Ext.W)) {
     644                                                if ((fext != Ext.W)) {
    648645                                                        nedge.nodes.add(2L);
    649                                                         if ((fext != Ext.SW) && (fext != Ext.S)) {
     646                                                        if ((fext != Ext.S)) {
    650647                                                                nedge.nodes.add(3L);
    651648                                                        }
     
    661658                        features.get(Obj.LNDARE).add(land);
    662659                }
     660                return;
    663661        }
    664662
    665663        // Utility methods
    666664       
    667         enum Ext {I, N, NW, W, SW, S, SE, E, NE }
     665        enum Ext {I, N, W, S, E }
     666        class Xnode {
     667                double lat;
     668                double lon;
     669                Ext ext;
     670        }
    668671        Ext outsideBounds(long ref) {
    669672                Snode node = nodes.get(ref);
    670673                if (node.lat >= bounds.maxlat) {
    671                         if (node.lon <= bounds.minlon) {
    672                                 return Ext.NW;
    673                         } else if (node.lon >= bounds.maxlon) {
    674                                 return Ext.NE;
    675                         }
    676674                        return Ext.N;
    677675                }
    678676                if (node.lat <= bounds.minlat) {
    679                         if (node.lon <= bounds.minlon) {
    680                                 return Ext.SW;
    681                         } else if (node.lon >= bounds.maxlon) {
    682                                 return Ext.SE;
    683                         }
    684677                        return Ext.S;
    685678                }
    686679                if (node.lon >= bounds.maxlon) {
    687                         if (node.lat <= bounds.minlat) {
    688                                 return Ext.SE;
    689                         } else if (node.lat >= bounds.maxlat) {
    690                                 return Ext.NE;
    691                         }
    692680                        return Ext.E;
    693681                }
    694682                if (node.lon <= bounds.minlon) {
    695                         if (node.lat <= bounds.minlat) {
    696                                 return Ext.SW;
    697                         } else if (node.lat >= bounds.maxlat) {
    698                                 return Ext.NW;
    699                         }
    700683                        return Ext.W;
    701684                }
     
    904887                int ec;
    905888                long lastref;
    906                
     889
    907890                public GeomIterator(Geom g) {
    908891                        geom = g;
Note: See TracChangeset for help on using the changeset viewer.