Changeset 28571 in osm for applications/editors/josm


Ignore:
Timestamp:
2012-08-19T01:22:45+02:00 (12 years ago)
Author:
zverik
Message:

final fixes

Location:
applications/editors/josm/plugins/poly
Files:
3 added
3 edited

Legend:

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

    r28570 r28571  
    9999                <attribute name="Plugin-Class" value="poly.PolyPlugin"/>
    100100                <attribute name="Plugin-Date" value="${version.entry.commit.date}"/>
    101                 <attribute name="Plugin-Description" value="Read and write osmosis' poly files"/>
     101                <attribute name="Plugin-Description" value="Read and write osmosis' poly filter files"/>
    102102                <attribute name="Plugin-Early" value="false"/>
    103103                <!--<attribute name="Plugin-Icon" value="images/pbf_24.png"/>-->
  • applications/editors/josm/plugins/poly/src/poly/PolyImporter.java

    r28570 r28571  
    9494                    parsingSection = false;
    9595                }
    96             }
    97 
    98             if( !parsingSection ) {
    99                 area = new Area(line);
    100                 parsingSection = true;
    10196            } else {
    102                 // reading area, parse coordinates
    103                 String[] tokens = line.split("\\s+");
    104                 double[] coords = new double[2];
    105                 int tokenCount = 0;
    106                 for( String token : tokens ) {
    107                     if( token.length() > 0 ) {
    108                         if( tokenCount > 2 )
    109                             throw new IllegalDataException(tr("A polygon coordinate line must contain exactly 2 numbers"));
    110                         try {
    111                             coords[tokenCount++] = Double.parseDouble(token);
    112                         } catch( NumberFormatException e ) {
    113                             throw new IllegalDataException(tr("Unable to parse {0} as a number", token));
     97                if( !parsingSection ) {
     98                    area = new Area(line);
     99                    parsingSection = true;
     100                } else {
     101                    // reading area, parse coordinates
     102                    String[] tokens = line.split("\\s+");
     103                    double[] coords = new double[2];
     104                    int tokenCount = 0;
     105                    for( String token : tokens ) {
     106                        if( token.length() > 0 ) {
     107                            if( tokenCount > 2 )
     108                                throw new IllegalDataException(tr("A polygon coordinate line must contain exactly 2 numbers"));
     109                            try {
     110                                coords[tokenCount++] = Double.parseDouble(token);
     111                            } catch( NumberFormatException e ) {
     112                                throw new IllegalDataException(tr("Unable to parse {0} as a number", token));
     113                            }
    114114                        }
    115115                    }
     116                    if( tokenCount < 2 )
     117                        throw new IllegalDataException(tr("A polygon coordinate line must contain exactly 2 numbers"));
     118                    LatLon coord = new LatLon(coords[1], coords[0]);
     119                    if( !coord.isValid() )
     120                        throw new IllegalDataException(tr("Invalid coordinates were found: {0}, {1}", coord.lat(), coord.lon()));
     121                    area.addNode(coord);
    116122                }
    117                 if( tokenCount < 2 )
    118                     throw new IllegalDataException(tr("A polygon coordinate line must contain exactly 2 numbers"));
    119                 LatLon coord = new LatLon(coords[1], coords[0]);
    120                 if( !coord.isValid() )
    121                     throw new IllegalDataException(tr("Invalid coordinates were found"));
    122                 area.addNode(coord);
    123123            }
    124124        }
     
    128128    private DataSet constructDataSet( List<Area> areas ) {
    129129        DataSet ds = new DataSet();
     130        ds.setUploadDiscouraged(true);
     131       
    130132        boolean foundInner = false;
    131133        for( Area area : areas ) {
     
    187189        public void constructWay( DataSet ds ) {
    188190            way = new Way();
    189             for( LatLon coord : nodes )
    190                 way.addNode(new Node(coord));
     191            for( LatLon coord : nodes ) {
     192                Node node = new Node(coord);
     193                ds.addPrimitive(node);
     194                way.addNode(node);
     195            }
    191196            way.addNode(way.getNode(0));
    192197            way.put("ref", name);
  • applications/editors/josm/plugins/poly/src/poly/PolyType.java

    r28570 r28571  
    1111public interface PolyType {
    1212    public static final String EXTENSION = "poly";
    13     public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(EXTENSION, EXTENSION, tr("Osmosis polygon files") + " (*." + EXTENSION + ")");
     13    public static final ExtensionFileFilter FILE_FILTER = new ExtensionFileFilter(EXTENSION, EXTENSION, tr("Osmosis polygon filter files") + " (*." + EXTENSION + ")");
    1414}
Note: See TracChangeset for help on using the changeset viewer.