Ignore:
Timestamp:
2012-03-19T00:23:49+01:00 (13 years ago)
Author:
donvip
Message:

opendata: large code reorganization, ask for license agreement before downloading, from embedded HTML/RTF files for ODbL and LO/OL

Location:
applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf/datasets/EquipementsHandler.java

    r28044 r28113  
     1//    JOSM opendata plugin.
     2//    Copyright (C) 2011-2012 Don-vip
     3//
     4//    This program is free software: you can redistribute it and/or modify
     5//    it under the terms of the GNU General Public License as published by
     6//    the Free Software Foundation, either version 3 of the License, or
     7//    (at your option) any later version.
     8//
     9//    This program is distributed in the hope that it will be useful,
     10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12//    GNU General Public License for more details.
     13//
     14//    You should have received a copy of the GNU General Public License
     15//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    116package org.openstreetmap.josm.plugins.opendata.modules.fr.sncf.datasets;
    217
     
    823public class EquipementsHandler extends SncfDataSetHandler {
    924
     25        private class LambertIICsvHandler extends InternalCsvHandler {
     26                @Override
     27                public LatLon getCoor(EastNorth en, String[] fields) {
     28                        // Lambert II coordinates offset by 2000000 (see http://fr.wikipedia.org/wiki/Projection_conique_conforme_de_Lambert#Projections_officielles_en_France_métropolitaine)
     29                        return super.getCoor(new EastNorth(en.getX(), en.getY()-2000000), fields);
     30                }
     31        }
     32       
    1033        public EquipementsHandler() {
    1134                super("equipementsgares");
     35                setCsvHandler(new LambertIICsvHandler());
    1236                setSingleProjection(lambert4Zones[1]); // Lambert II
    1337        }
     
    2549                }
    2650        }
    27 
    28         /* (non-Javadoc)
    29          * @see org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler#getSpreadSheetCoor(org.openstreetmap.josm.data.coor.EastNorth, java.lang.String[])
    30          */
    31         @Override
    32         public LatLon getSpreadSheetCoor(EastNorth en, String[] fields) {
    33                 // Lambert II coordinates offset by 2000000 (see http://fr.wikipedia.org/wiki/Projection_conique_conforme_de_Lambert#Projections_officielles_en_France_métropolitaine)
    34                 return super.getSpreadSheetCoor(new EastNorth(en.getX(), en.getY()-2000000), fields);
    35         }
    3651}
  • applications/editors/josm/plugins/opendata/modules/fr.sncf/src/org/openstreetmap/josm/plugins/opendata/modules/fr/sncf/datasets/SncfDataSetHandler.java

    r28044 r28113  
     1//    JOSM opendata plugin.
     2//    Copyright (C) 2011-2012 Don-vip
     3//
     4//    This program is free software: you can redistribute it and/or modify
     5//    it under the terms of the GNU General Public License as published by
     6//    the Free Software Foundation, either version 3 of the License, or
     7//    (at your option) any later version.
     8//
     9//    This program is distributed in the hope that it will be useful,
     10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
     11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12//    GNU General Public License for more details.
     13//
     14//    You should have received a copy of the GNU General Public License
     15//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    116package org.openstreetmap.josm.plugins.opendata.modules.fr.sncf.datasets;
    217
    318import java.net.MalformedURLException;
    4 import java.net.URL;
    519
    620import org.openstreetmap.josm.data.osm.Tag;
    721import org.openstreetmap.josm.plugins.opendata.core.datasets.fr.FrenchDataSetHandler;
    822import org.openstreetmap.josm.plugins.opendata.modules.fr.sncf.SncfConstants;
     23import org.openstreetmap.josm.plugins.opendata.modules.fr.sncf.SncfLicense;
    924
    1025public abstract class SncfDataSetHandler extends FrenchDataSetHandler implements SncfConstants {
    11        
    12         private String portalId;
    1326       
    1427        public SncfDataSetHandler(String portalId) {
     
    4558       
    4659        private final void init(String portalId) {
    47                 this.portalId = portalId;
     60                setLicense(new SncfLicense());
     61                if (portalId != null && !portalId.isEmpty()) {
     62                        try {
     63                                setLocalPortalURL(PORTAL + portalId);
     64                        } catch (MalformedURLException e) {
     65                                e.printStackTrace();
     66                        }
     67                }
    4868        }
    4969
     
    7191                return ICON_16;
    7292        }
    73 
    74         public final URL getLocalPortalURL() {
    75                 try {
    76                         if (portalId != null) {
    77                                 return new URL(PORTAL + portalId);
    78                         }
    79                 } catch (MalformedURLException e) {
    80                         e.printStackTrace();
    81                 }
    82                 return null;
    83         }
    84 
    85         /* (non-Javadoc)
    86          * @see org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler#getLicenseURL()
    87          */
    88         @Override
    89         public URL getLicenseURL() {
    90                 try {
    91                         return new URL("http://test.data-sncf.com/licence");
    92                 } catch (MalformedURLException e) {
    93                         e.printStackTrace();
    94                 }
    95                 return null;
    96         }
    9793}
Note: See TracChangeset for help on using the changeset viewer.