Ignore:
Timestamp:
2014-08-07T02:09:00+02:00 (10 years ago)
Author:
donvip
Message:

[josm_opendata] enhancements to MapInfo .mif file reading + bugfixes + improved unit tests + add mapinfo documentation because of previous dead link

Location:
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/AbstractImporter.java

    r30563 r30573  
    22package org.openstreetmap.josm.plugins.opendata.core.io;
    33
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5
    46import java.io.File;
     7import java.io.FileInputStream;
     8import java.io.FileNotFoundException;
    59import java.io.IOException;
     10import java.io.InputStream;
    611
     12import org.openstreetmap.josm.Main;
    713import org.openstreetmap.josm.actions.ExtensionFileFilter;
    814import org.openstreetmap.josm.data.osm.DataSet;
     
    4551                        this.handler = findDataSetHandler(file);
    4652                }
    47                 super.importData(file, progressMonitor);
     53                // Do not call super.importData because Compression.getUncompressedFileInputStream skips the first entry
     54        try (InputStream in = new FileInputStream(file)) {
     55            importData(in, file, progressMonitor);
     56        } catch (FileNotFoundException e) {
     57            Main.error(e);
     58            throw new IOException(tr("File ''{0}'' does not exist.", file.getName()), e);
     59        }
    4860        }
    4961
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReader.java

    r30568 r30573  
    1818import javax.xml.stream.XMLStreamException;
    1919
     20import org.openstreetmap.josm.Main;
    2021import org.openstreetmap.josm.data.osm.DataSet;
    2122import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    4546    protected void extractArchive(final File temp, final List<File> candidates) throws IOException, FileNotFoundException {
    4647        while ((entry = zis.getNextEntry()) != null) {
     48            if (Main.isDebugEnabled()) {
     49                Main.debug("Extracting "+entry.getName());
     50            }
    4751            File file = new File(temp + File.separator + entry.getName());
    4852            File parent = file.getParentFile();
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifDatum.java

    r30340 r30573  
    44import static org.openstreetmap.josm.plugins.opendata.core.io.geographic.MifEllipsoid.*;
    55
    6 // TODO: finish
     6/**
     7 * MapInfo Interchange File (MIF) datums, based on this specification:<ul>
     8 * <li><a href="https://github.com/tricycle/electrodrive-market-analysis/blob/master/specifications/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf</a></li>
     9 * </ul>
     10 * This file has been stored in reference directory to avoid future dead links.
     11 */
    712public enum MifDatum {
    8         Adindan(1, Clarke_1880),
    9         Afgooye(2, Krassovsky),
    10         Ain_el_Abd_1970(3, International),
    11         Anna_1_Astro_1965(4, Australian_National),
    12         Arc_1950(5, Clarke_1880),
    13         Arc_1960(6, Clarke_1880),
    14         Ascension_Island_1958(7, International),
    15         Astro_Beacon_E(8, International),
    16         Astro_B4_Sorol_Atoll(9, International),
    17         Astro_DOS_71_4(10, International),
    18         Astronomic_Station_1952(11, International),
    19         Australian_Geodetic_1966_AGD_66(12, Australian_National),
    20         Australian_Geodetic_1984_AGD_84(13, Australian_National),
    21         Belgium(110, International),
    22         Bellevue_IGN(14, International),
    23         Bermuda_1957(15, Clarke_1866),
    24         Bogota_Observatory(16, International),
    25 //17 Campo_Inchauspe Argentina International),
    26 //18 Canton_Astro_1966 Phoenix Islands International),
    27 //19 Cape South Africa Clarke_1880),
    28 //20 Cape Canaveral Florida and Bahama Islands Clarke_1866),
    29 //21 Carthage Tunisia Clarke_1880),
    30 //22 Chatham 1971 Chatham Island (New Zealand) International),
    31 //23 Chua Astro Paraguay International),
    32 //24 Corrego Alegre Brazil International),
    33 //1000 Deutsches        Hauptdreicksnetz        (DHDN)  Germany Bessel),
    34 //25 Djakarta (Batavia) Sumatra Island (Indonesia) Bessel 1841),
    35 //26 DOS 1968 Gizo Island (New Georgia Islands) International),
    36 //27 Easter Island 1967 Easter Island International),
    37         European_1950_ED_50(28, International),
    38         European_1979_ED_79(29, International),
    39         European_1987_ED_87(108, International),
    40         Gandajika_Base(30, International),
    41         Geodetic_Datum_1949(31, International),
    42         Geodetic_Reference_System_1967_GRS_67(32, GRS_67),
    43         Geodetic_Reference_System_1980_GRS_80(33, GRS_80),
    44 //34 Guam 1963 Guam Island Clarke_1866),
    45 //35 GUX 1 Astro Guadalcanal Island International),
    46 //36 Hito XVIII 1963 South Chile (near 53°S) International),
    47 //37 Hjorsey 1955 Iceland International),
    48 //38 Hong Kong 1963 Hong Kong International),
    49 //39 Hu–Tzu–Shan Taiwan International),
    50 //40 Indian Thailand and Vietnam Everest),
    51 //41 Indian Bangladesh, India, Nepal Everest),
    52 //42 Ireland 1965 Ireland Modified Airy),
    53 //43 ISTS 073 Astro 1969 Diego Garcia International),
    54 //44 Johnston Island 1961 Johnston Island International),
    55 //45 Kandawala Sri Lanka Everest),
    56 //46 Kerguelen Island Kerguelen Island International),
    57 //47 Kertau 1948 West Malaysia and Singapore Modified Everest),
    58 //48 L.C. 5 Astro Cayman Brac Island Clarke_1866),
    59 //49 Liberia 1964 Liberia Clarke_1880),
    60 //113 Lisboa (DLx) Portugal International),
    61 //50 Luzon Philippines (excluding Mindanao Island) Clarke_1866),
    62 //51 Luzon Mindanao Island Clarke_1866),
    63 //52 Mahe 1971 Mahe Island Clarke_1880),
    64 //53 Marco Astro Salvage Islands International),
    65 //54 Massawa Eritrea (Ethiopia) Bessel 1841),
    66 //114 Melrica 1973 (D73) Portugal International),
    67 //55 Merchich Morocco Clarke_1880),
    68 //56 Midway Astro 1961 Midway Island International),
    69 //57 Minna Nigeria Clarke_1880),
    70 //58 Nahrwan Masirah Island (Oman) Clarke_1880),
    71 //59 Nahrwan United Arab Emirates Clarke_1880),
    72 //60 Nahrwan Saudi Arabia Clarke_1880),
    73 //61 Naparima, BWI Trinidad and Tobago International),
    74 //109 Netherlands Netherlands Bessel),
    75         North_American_1927_NAD_27_CONTINENTAL(62, Clarke_1866),
    76         North_American_1927_NAD_27_ALASKA(63, Clarke_1866),
    77         North_American_1927_NAD_27_BAHAMAS(64, Clarke_1866),
    78         North_American_1927_NAD_27_SAN_SALVADOR(65, Clarke_1866),
    79         North_American_1927_NAD_27_CANADA(66, Clarke_1866),
    80         North_American_1927_NAD_27_CANAL_ZONE(67, Clarke_1866),
    81         North_American_1927_NAD_27_CARIBBEAN(68, Clarke_1866),
    82         North_American_1927_NAD_27_CENTRAL_AMERICA(69, Clarke_1866),
    83         North_American_1927_NAD_27_CUBA(70, Clarke_1866),
    84         North_American_1927_NAD_27_GREENLAND(71, Clarke_1866),
    85         North_American_1927_NAD_27_MEXICO(72, Clarke_1866),
    86         North_American_1927_NAD_27_MICHIGAN(73, Modified_Clarke_1866),
    87         North_American_1983_NAD_83(74, GRS_80),
    88         Nouvelle_Triangulation_Francaise_NTF(107, Clarke_1880),
    89         Nouvelle_Triangulation_Francaise_NTF_Greenwich_Prime_Meridian(1002, Clarke_1880),
    90         NWGL_10(111, WGS_72),
    91 //75 Observatorio 1966 Corvo and Flores Islands (Azores) International),
    92 //76 Old Egyptian Egypt Helmert 1906),
    93 //77 Old Hawaiian Hawaii Clarke_1866),
    94 //78 Oman Oman Clarke_1880),
    95 //79 Ordnance Survey of Great Britain 1936 England, Isle of Man, Scotland, Shetland Islands, Wales Airy),
    96 //80 Pico de las Nieves Canary Islands International),
    97 //81 Pitcairn Astro 1967 Pitcairn Island International),
    98 //1000 Potsdam Germany Bessel),
    99 //36 Provisional South Chilean 1963 South Chile (near 53°S) International),
    100 //82 Provisional South American 1956 Bolivia, Chile, Colombia, Ecuador, Guyana, Peru, Venezuela International),
    101 //83 Puerto Rico Puerto Rico and Virgin Islands Clarke_1866),
    102 //1001 Pulkovo 1942 Germany Krassovsky),
    103 //84 Qatar National Qatar International),
    104 //85 Qornoq South Greenland International),
    105 //1000 Rauenberg Germany Bessel),
    106 //86 Reunion Mascarene Island International),
    107 //112 Rikets Triangulering 1990 (RT 90) Sweden Bessel),
    108 //87 Rome 1940 Sardinia Island International),
    109 //88 Santo (DOS) Espirito Santo Island International),
    110 //89 São Braz São Miguel, Santa Maria Islands (Azores) International),
    111 //90 Sapper Hill 1943 East Falkland Island International),
    112 //91 Schwarzeck Namibia Modified Bessel 1841),
    113 //92 South American 1969 Argentina, Bolivia, Brazil, Chile, Colombia, Ecuador, Guyana, Paraguay, Peru, Venezuela, Trinidad, and Tobago South American 1969),
    114 //93 South Asia Singapore Modified Fischer 1960),
    115 //94 Southeast Base Porto Santo and Madeira Islands International),
    116 //95 Southwest Base Faial, Graciosa, Pico, Sao Jorge, Terceira Islands (Azores) International),
    117 //1003 Switzerland (CH 1903) Switzerland Bessel),
    118 //96 Timbalai 1948 Brunei and East Malaysia (Sarawak and Sabah) Everest),
    119 //97 Tokyo Japan, Korea, Okinawa Bessel 1841),
    120 //98 Tristan Astro 1968 Tristan da Cunha International),
    121 //99 Viti Levu 1916 Viti Levu Island (Fiji Islands) Clarke_1880),
    122         Wake_Eniwetok_1960(100, Hough),
    123         World_Geodetic_System_1960_WGS_60(101, WGS_60),
    124         World_Geodetic_System_1966_WGS_66(102, WGS_66),
    125         World_Geodetic_System_1972_WGS_72(103, WGS_72),
    126         World_Geodetic_System_1984_WGS_84(104, WGS_84),
    127         Yacare(105, International),
    128         Zanderij(106, International),
    129         Custom(999, null);
     13        Adindan(1, "Ethiopia, Mali, Senegal, Sudan", Clarke_1880),
     14        Afgooye(2, "Somalia", Krassovsky),
     15        Ain_el_Abd_1970(3, "Bahrain Island", International),
     16        Anna_1_Astro_1965(4, "Cocos Islands", Australian_National),
     17        Arc_1950(5, "Botswana, Lesotho, Malawi, Swaziland, Zaire, Zambia, Zimbabwe", Clarke_1880),
     18        Arc_1960(6, "Kenya, Tanzania", Clarke_1880),
     19        Ascension_Island_1958(7, "Ascension Island", International),
     20        Astro_Beacon_E(8, "Iwo Jima Island", International),
     21        Astro_B4_Sorol_Atoll(9, "Tern Island", International),
     22        Astro_DOS_71_4(10, "St. Helena Island", International),
     23        Astronomic_Station_1952(11, "Marcus Island", International),
     24        Australian_Geodetic_1966_AGD_66(12, "Australia and Tasmania Island", Australian_National),
     25        Australian_Geodetic_1984_AGD_84(13, "Australia and Tasmania Island", Australian_National),
     26        Belgium(110, "Belgium", International),
     27        Bellevue_IGN(14, "Efate and Erromango Islands", International),
     28        Bermuda_1957(15, "Bermuda Islands", Clarke_1866),
     29        Bogota_Observatory(16, "Colombia", International),
     30        Campo_Inchauspe(17, "Argentina", International),
     31    Canton_Astro_1966(18, "Phoenix Islands", International),
     32    Cape(19, "South Africa", Clarke_1880),
     33    Cape_Canaveral(20, "Florida and Bahama Islands", Clarke_1866),
     34    Carthage(21, "Tunisia", Clarke_1880),
     35    Chatham_1971(22, "Chatham Island (New Zealand)", International),
     36    Chua_Astro(23, "Paraguay", International),
     37    Corrego_Alegre(24, "Brazil", International),
     38    Deutsches_Hauptdreicksnetz_DHDN(1000, "Germany", Bessel),
     39    Djakarta_Batavia(25, "Sumatra Island (Indonesia)", Bessel_1841),
     40    DOS_1968(26, "Gizo Island (New Georgia Islands)", International),
     41    Easter_Island_1967(27, "Easter Island", International),
     42        European_1950_ED_50(28, "Austria, Belgium, Denmark, Finland, France, Germany, Gibraltar, Greece, Italy, Luxembourg, Netherlands, Norway, Portugal, Spain, Sweden, Switzerland", International),
     43        European_1979_ED_79(29, "Austria, Finland, Netherlands, Norway, Spain, Sweden, Switzerland", International),
     44        European_1987_ED_87(108, "Europe", International),
     45        Gandajika_Base(30, "Republic of Maldives", International),
     46        Geodetic_Datum_1949(31, "New Zealand", International),
     47        Geodetic_Reference_System_1967_GRS_67(32, "Worldwide", GRS_67),
     48        Geodetic_Reference_System_1980_GRS_80(33, "Worldwide", GRS_80),
     49        Guam_1963(34, "Guam Island", Clarke_1866),
     50        GUX_1_Astro(35, "Guadalcanal Island", International),
     51        Hito_XVIII_1963(36, "South Chile (near 53°S)", International),
     52        Hjorsey_1955(37, "Iceland", International),
     53        Hong_Kong_1963(38, "Hong Kong", International),
     54        Hu_Tzu_Shan(39, "Taiwan", International),
     55        Indian_40(40, "Thailand and Vietnam", Everest),
     56        Indian_41(41, "Bangladesh, India, Nepal", Everest),
     57        Ireland_1965(42, "Ireland", Modified_Airy),
     58        ISTS_073_Astro_1969(43, "Diego Garcia", International),
     59        Johnston_Island_1961(44, "Johnston Island", International),
     60        Kandawala(45, "Sri Lanka", Everest),
     61        Kerguelen_Island(46, "Kerguelen Island", International),
     62        Kertau_1948(47, "West Malaysia and Singapore", Modified_Everest),
     63        LC_5_Astro(48, "Cayman Brac Island", Clarke_1866),
     64        Liberia_1964(49, "Liberia", Clarke_1880),
     65        Lisboa_DLx(113, "Portugal", International),
     66        Luzon_50(50, "Philippines (excluding Mindanao Island)", Clarke_1866),
     67        Luzon_51(51, "Mindanao Island", Clarke_1866),
     68    Mahe_1971(52, "Mahe Island", Clarke_1880),
     69    Marco_Astro(53, "Salvage Islands", International),
     70    Massawa(54, "Eritrea (Ethiopia)", Bessel_1841),
     71    Melrica_1973_D73(114, "Portugal", International),
     72    Merchich(55, "Morocco", Clarke_1880),
     73    Midway_Astro_1961(56, "Midway Island", International),
     74    Minna(57, "Nigeria", Clarke_1880),
     75    Nahrwan_58(58, "Masirah Island (Oman)", Clarke_1880),
     76    Nahrwan_59(59, "United Arab Emirates", Clarke_1880),
     77    Nahrwan_60(60, "Saudi Arabia", Clarke_1880),
     78    Naparima_BWI(61, "Trinidad and Tobago", International),
     79    Netherlands(109, "Netherlands", Bessel),
     80        North_American_1927_NAD_27_CONTINENTAL(62, "Continental US", Clarke_1866),
     81        North_American_1927_NAD_27_ALASKA(63, "Alaska", Clarke_1866),
     82        North_American_1927_NAD_27_BAHAMAS(64, "Bahamas (excluding San Salvador Island)", Clarke_1866),
     83        North_American_1927_NAD_27_SAN_SALVADOR(65, "San Salvador Island", Clarke_1866),
     84        North_American_1927_NAD_27_CANADA(66, "Canada (including Newfoundland Island)", Clarke_1866),
     85        North_American_1927_NAD_27_CANAL_ZONE(67, "Canal Zone", Clarke_1866),
     86        North_American_1927_NAD_27_CARIBBEAN(68, "Caribbean (Turks and Caicos Islands)", Clarke_1866),
     87        North_American_1927_NAD_27_CENTRAL_AMERICA(69, "Central America (Belize, Costa Rica, El Salvador, Guatemala, Honduras, Nicaragua)", Clarke_1866),
     88        North_American_1927_NAD_27_CUBA(70, "Cuba", Clarke_1866),
     89        North_American_1927_NAD_27_GREENLAND(71, "Greenland (Hayes Peninsula)", Clarke_1866),
     90        North_American_1927_NAD_27_MEXICO(72, "Mexico", Clarke_1866),
     91        North_American_1927_NAD_27_MICHIGAN(73, "Michigan (used only for State Plane Coordinate System 1927)", Modified_Clarke_1866),
     92        North_American_1983_NAD_83(74, "Alaska, Canada, Central America, Continental US, Mexico", GRS_80),
     93        Nouvelle_Triangulation_Francaise_NTF(107, "France", Clarke_1880),
     94        Nouvelle_Triangulation_Francaise_NTF_Greenwich_Prime_Meridian(1002, "France", Clarke_1880),
     95        NWGL_10(111, "Worldwide", WGS_72),
     96    Observatorio_1966(75, "Corvo and Flores Islands (Azores)", International),
     97    Old_Egyptian(76, "Egypt", Helmert_1906),
     98    Old_Hawaiian(77, "Hawaii", Clarke_1866),
     99    Oman(78, "Oman", Clarke_1880),
     100    Ordnance_Survey_of_Great_Britain_1936(79, "England, Isle of Man, Scotland, Shetland Islands, Wales", Airy),
     101    Pico_de_las_Nieves(80, "Canary Islands", International),
     102    Pitcairn_Astro_1967(81, "Pitcairn Island", International),
     103    Potsdam(1000, "Germany", Bessel),
     104    Provisional_South_Chilean_1963(36, "South Chile (near 53°S)", International),
     105    Provisional_South_American_1956(82, "Bolivia, Chile, Colombia, Ecuador, Guyana, Peru, Venezuela", International),
     106    Puerto_Rico(83, "Puerto Rico and Virgin Islands", Clarke_1866),
     107    Pulkovo_1942(1001, "Germany", Krassovsky),
     108    Qatar_National(84, "Qatar", International),
     109    Qornoq(85, "South Greenland", International),
     110    Rauenberg(1000, "Germany", Bessel),
     111    Reunion(86, "Mascarene Island", International),
     112    Rikets_Triangulering_1990_RT_90(112, "Sweden", Bessel),
     113    Rome_1940(87, "Sardinia Island", International),
     114    Santo_DOS(88, "Espirito Santo Island", International),
     115    Sao_Braz(89, "São Miguel, Santa Maria Islands (Azores)", International),
     116    Sapper_Hill_1943(90, "East Falkland Island", International),
     117    Schwarzeck(91, "Namibia Modified", Bessel_1841),
     118    South_American_1969(92, "Argentina, Bolivia, Brazil, Chile, Colombia, Ecuador, Guyana, Paraguay, Peru, Venezuela, Trinidad, and Tobago", MifEllipsoid.South_American_1969),
     119    South_Asia(93, "Singapore", Modified_Fischer_1960),
     120    Southeast_Base(94, "Porto Santo and Madeira Islands", International),
     121    Southwest_Base(95, "Faial, Graciosa, Pico, Sao Jorge, Terceira Islands (Azores)", International),
     122    Switzerland_CH_1903(1003, "Switzerland", Bessel),
     123    Timbalai_1948(96, "Brunei and East Malaysia (Sarawak and Sabah)", Everest),
     124    Tokyo(97, "Japan, Korea, Okinawa", Bessel_1841),
     125    Tristan_Astro_1968(98, "Tristan da Cunha", International),
     126    Viti_Levu_1916(99, "Viti Levu Island (Fiji Islands)", Clarke_1880),
     127        Wake_Eniwetok_1960(100, "", Hough),
     128        World_Geodetic_System_1960_WGS_60(101, "", WGS_60),
     129        World_Geodetic_System_1966_WGS_66(102, "", WGS_66),
     130        World_Geodetic_System_1972_WGS_72(103, "", WGS_72),
     131        World_Geodetic_System_1984_WGS_84(104, "", WGS_84),
     132        Yacare(105, "", International),
     133        Zanderij(106, "", International),
     134        Custom(999, null, null);
    130135       
    131136        private final Integer code;
     137    private final String area;
    132138        private final MifEllipsoid ellipsoid;
    133         private MifDatum(Integer code, MifEllipsoid ellipsoid) {
     139        private MifDatum(Integer code, String area, MifEllipsoid ellipsoid) {
    134140                this.code = code;
     141                this.area = area;
    135142                this.ellipsoid = ellipsoid;
    136143        }
     
    138145                return code;
    139146        }
     147    public final String getArea() {
     148        return area;
     149    }
    140150        public final MifEllipsoid getEllipsoid() {
    141151                return ellipsoid;
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifEllipsoid.java

    r30340 r30573  
    22package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
    33
     4/**
     5 * MapInfo Interchange File (MIF) ellipsoids, based on this specification:<ul>
     6 * <li><a href="https://github.com/tricycle/electrodrive-market-analysis/blob/master/specifications/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf</a></li>
     7 * </ul>
     8 * This file has been stored in reference directory to avoid future dead links.
     9 */
    410public enum MifEllipsoid {
    511        Airy,
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifProjection.java

    r30340 r30573  
    22package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
    33
     4/**
     5 * MapInfo Interchange File (MIF) projections, based on this specification:<ul>
     6 * <li><a href="https://github.com/tricycle/electrodrive-market-analysis/blob/master/specifications/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf</a></li>
     7 * </ul>
     8 * This file has been stored in reference directory to avoid future dead links.
     9 */
    410public enum MifProjection {
    5         Albers_Equal_Area_Conic(9),
    6         Azimuthal_Equidistant_polar_aspect_only(5),
    7         Cylindrical_Equal_Area(2),
    8         Eckert_IV(14),
    9         Eckert_VI(15),
    10         Equidistant_Conic_also_known_as_Simple_Conic(6),
    11         Gall(17),
    12         Hotine_Oblique_Mercator(7),
    13         Lambert_Azimuthal_Equal_Area_polar_aspect_only(4),
    14         Lambert_Conformal_Conic(3),
    15         Lambert_Conformal_Conic_modified_for_Belgium_1972(19),
    16         Longitude_Latitude(1),
    17         Mercator(10),
    18         Miller_Cylindrical(11),
    19         New_Zealand_Map_Grid(18),
    20         Mollweide(13),
    21         Polyconic(27),
    22         Regional_Mercator(26),
    23         Robinson(12),
    24         Sinusoidal(16),
    25         Stereographic(20),
    26         Swiss_Oblique_Mercator(25),
    27         Transverse_Mercator_also_known_as_Gauss_Kruger(8),
    28         Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn(21),
    29         Transverse_Mercator_modified_for_Sjaelland(22),
    30         Transverse_Mercator_modified_for_Danish_System_45_Bornholm(23),
    31         Transverse_Mercator_modified_for_Finnish_KKJ(24);
     11        Albers_Equal_Area_Conic(9, "aea"),
     12        Azimuthal_Equidistant_polar_aspect_only(5, "aeqd"),
     13        Cylindrical_Equal_Area(2, "cea"),
     14        Eckert_IV(14, "eck4"),
     15        Eckert_VI(15, "eck6"),
     16        Equidistant_Conic_also_known_as_Simple_Conic(6, "eqdc"),
     17        Gall(17, "gall"),
     18        Hotine_Oblique_Mercator(7, "omerc"),
     19        Lambert_Azimuthal_Equal_Area_polar_aspect_only(4, "laea"),
     20        Lambert_Conformal_Conic(3, "lcc"),
     21        Lambert_Conformal_Conic_modified_for_Belgium_1972(19, "lcca"),
     22        Longitude_Latitude(1, "lonlat"),
     23        Mercator(10, "merc"),
     24        Miller_Cylindrical(11, "mill"),
     25        New_Zealand_Map_Grid(18, "nzmg"),
     26        Mollweide(13, "moll"),
     27        Polyconic(27, "poly"),
     28        Regional_Mercator(26, "merc"),
     29        Robinson(12, "robin"),
     30        Sinusoidal(16, "sinu"),
     31        Stereographic(20, "stere"),
     32        Swiss_Oblique_Mercator(25, "somerc"),
     33        Transverse_Mercator_also_known_as_Gauss_Kruger(8, "tmerc"),
     34        Transverse_Mercator_modified_for_Danish_System_34_Jylland_Fyn(21, "tmerc"),
     35        Transverse_Mercator_modified_for_Sjaelland(22, "tmerc"),
     36        Transverse_Mercator_modified_for_Danish_System_45_Bornholm(23, "tmerc"),
     37        Transverse_Mercator_modified_for_Finnish_KKJ(24, "tmerc");
    3238       
    3339        private final Integer code;
    34         private MifProjection(Integer code) {
     40        private final String proj4id;
     41       
     42        private MifProjection(Integer code, String proj4id) {
    3543                this.code = code;
     44                this.proj4id = proj4id;
    3645        }
     46       
    3747        public final Integer getCode() {
    3848                return code;
    3949        }
     50   
     51        /**
     52     * Replies the Proj.4 identifier.
     53     *
     54     * @return The Proj.4 identifier (as reported by cs2cs -lp).
     55     * If no id exists, return {@code null}.
     56     */
     57    public final String getProj4Id() {
     58        return proj4id;
     59    }
     60   
    4061        public static MifProjection forCode(Integer code) {
    4162                for (MifProjection p : values()) {
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReader.java

    r30563 r30573  
    2424import org.openstreetmap.josm.data.osm.RelationMember;
    2525import org.openstreetmap.josm.data.osm.Way;
     26import org.openstreetmap.josm.data.projection.CustomProjection;
     27import org.openstreetmap.josm.data.projection.CustomProjection.Param;
    2628import org.openstreetmap.josm.data.projection.Projection;
    2729import org.openstreetmap.josm.data.projection.Projections;
     
    3335/**
    3436 * MapInfo Interchange File (MIF) reader, based on these specifications:<ul>
    35  * <li><a href="http://www.gissky.com/Download/Download/DataFormat/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf (dead link)</a></li>
     37 * <li><a href="https://github.com/tricycle/electrodrive-market-analysis/blob/master/specifications/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf</a></li>
    3638 * <li><a href="http://resource.mapinfo.com/static/files/document/1074660800077/interchange_file.pdf">interchange_file.pdf</a></li>
    3739 * </ul>
     40 * These files have been stored in reference directory to avoid future dead links.
    3841 */
    3942public class MifReader extends AbstractMapInfoReader {
     
    102105        Main.warn("TODO Index: "+line);
    103106    }
     107   
     108    private static String param(Param p, Object value) {
     109        return " +"+p.key+"="+value;
     110    }
    104111
    105112    private void parseCoordSysSyntax1(String[] words) {
     
    115122        }
    116123       
     124        // Initialize proj4-like parameters
     125        String params = param(Param.proj, proj.getProj4Id());
     126       
    117127        // Units
    118128        units = words[5+offset];
     129        params += param(Param.units, units);
    119130       
    120131        // Origin, longitude
    121132        originLon = Double.parseDouble(words[6+offset]);
     133        params += param(Param.lon_0, originLon);
    122134       
    123135        // Origin, latitude
     
    140152        case Polyconic:
    141153            originLat = Double.parseDouble(words[7+offset]);
     154            params += param(Param.lat_0, originLat);
    142155            break;
    143156        }
     
    148161        case Regional_Mercator:
    149162            stdP1 = Double.parseDouble(words[7+offset]);
     163            params += param(Param.lat_1, stdP1);
    150164            break;
    151165        case Albers_Equal_Area_Conic:
     
    154168        case Lambert_Conformal_Conic_modified_for_Belgium_1972:
    155169            stdP1 = Double.parseDouble(words[8+offset]);
     170            params += param(Param.lat_1, stdP1);
    156171            break;
    157172        }
     
    164179        case Lambert_Conformal_Conic_modified_for_Belgium_1972:
    165180            stdP2 = Double.parseDouble(words[9+offset]);
     181            params += param(Param.lat_2, stdP2);
    166182            break;
    167183        }
     
    170186        if (proj == Hotine_Oblique_Mercator) {
    171187            azimuth = Double.parseDouble(words[8+offset]);
     188            // TODO: what's proj4 parameter ?
    172189        }
    173190
     
    176193        case Hotine_Oblique_Mercator:
    177194            scaleFactor = Double.parseDouble(words[9+offset]);
     195            params += param(Param.k_0, scaleFactor);
    178196            break;
    179197        case Stereographic:
     
    184202        case Transverse_Mercator_modified_for_Sjaelland:
    185203            scaleFactor = Double.parseDouble(words[8+offset]);
     204            params += param(Param.k_0, scaleFactor);
    186205            break;
    187206        }
     
    196215            falseEasting = Double.parseDouble(words[10+offset]);
    197216            falseNorthing = Double.parseDouble(words[11+offset]);
     217            params += param(Param.x_0, falseEasting);
     218            params += param(Param.y_0, falseNorthing);
    198219            break;
    199220        case Stereographic:
     
    205226            falseEasting = Double.parseDouble(words[9+offset]);
    206227            falseNorthing = Double.parseDouble(words[10+offset]);
     228            params += param(Param.x_0, falseEasting);
     229            params += param(Param.y_0, falseNorthing);
    207230            break;
    208231        case New_Zealand_Map_Grid:
     
    211234            falseEasting = Double.parseDouble(words[8+offset]);
    212235            falseNorthing = Double.parseDouble(words[9+offset]);
     236            params += param(Param.x_0, falseEasting);
     237            params += param(Param.y_0, falseNorthing);
    213238            break;
    214239        }
     
    219244        case Lambert_Azimuthal_Equal_Area_polar_aspect_only:
    220245            range = Double.parseDouble(words[8+offset]);
     246            // TODO: what's proj4 parameter ?
    221247        }
    222248
     
    236262            }
    237263            break;
    238         default:
    239             // TODO
    240             Main.warn("TODO proj: "+line);
    241264        }
    242265       
     
    246269        // handle cases with Bounds declaration
    247270        parseBounds(words, index);
     271       
     272        if (josmProj == null) {
     273            Main.info(line);
     274            Main.info(params);
     275            josmProj = new CustomProjection(params);
     276        }
    248277    }
    249278
     
    344373
    345374    private void parseRegion(String[] words) throws IOException {
    346         region = new Relation();
    347         region.put("type", "multipolygon");
    348         ds.addPrimitive(region);
    349         readAttributes(region);
    350375        numpolygons = Integer.parseInt(words[1]);
     376        if (numpolygons > 1) {
     377            region = new Relation();
     378            region.put("type", "multipolygon");
     379            ds.addPrimitive(region);
     380            readAttributes(region);
     381        } else {
     382            region = null;
     383        }
    351384        state = State.START_POLYGON;
    352385    }
     
    416449                polygon = new Way();
    417450                ds.addPrimitive(polygon);
    418                 region.addMember(new RelationMember("outer", polygon));
     451                if (region != null) {
     452                    region.addMember(new RelationMember("outer", polygon));
     453                } else {
     454                    readAttributes(polygon);
     455                }
    419456                state = State.READING_POINTS;
    420457               
     
    437474                if (--numpts == 0) {
    438475                    if (numpolygons > -1) {
     476                        if (!polygon.isClosed()) {
     477                            polygon.addNode(polygon.firstNode());
     478                        }
    439479                        if (--numpolygons > 0) {
    440480                            state = State.START_POLYGON;
  • applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifUnit.java

    r30340 r30573  
    22package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
    33
     4/**
     5 * MapInfo Interchange File (MIF) units, based on this specification:<ul>
     6 * <li><a href="https://github.com/tricycle/electrodrive-market-analysis/blob/master/specifications/Mapinfo_Mif.pdf">Mapinfo_Mif.pdf</a></li>
     7 * </ul>
     8 * This file has been stored in reference directory to avoid future dead links.
     9 */
    410public enum MifUnit {
    511        Centimeters(6),
Note: See TracChangeset for help on using the changeset viewer.