Ignore:
Timestamp:
2016-09-03T16:43:42+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/seachart/josmtos57/src/josmtos57/Josmtos57.java

    r32906 r32907  
    1 /* Copyright 2015 Malcolm Herring
    2  *
    3  * This is free software: you can redistribute it and/or modify
    4  * it under the terms of the GNU General Public License as published by
    5  * the Free Software Foundation, version 3 of the License.
    6  *
    7  * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
    8  */
    9 
     1// License: GPL. For details, see LICENSE file.
    102package josmtos57;
    113
    12 import java.io.*;
    13 import java.util.*;
     4import java.io.BufferedReader;
     5import java.io.File;
     6import java.io.FileInputStream;
     7import java.io.FileOutputStream;
     8import java.io.FileReader;
     9import java.io.IOException;
     10import java.io.UnsupportedEncodingException;
     11import java.util.ArrayList;
     12import java.util.Arrays;
     13import java.util.HashMap;
     14import java.util.Scanner;
    1415import java.util.zip.CRC32;
    1516
    1617import s57.S57dat;
     18import s57.S57dat.Fparams;
     19import s57.S57dat.S57field;
    1720import s57.S57enc;
    1821import s57.S57map;
    1922import s57.S57osm;
    20 import s57.S57dat.*;
    2123
    22 public class Josmtos57 {
     24/**
     25 * @author Malcolm Herring
     26 */
     27public final class Josmtos57 {
     28    private Josmtos57() {
     29        // Hide default constructor for utilities classes
     30    }
    2331
    2432    // http://opendatacommons.org/licenses/odbl/1-0/
    25    
     33
    2634    /*
    2735    URL website = new URL("http://www.website.com/information.asp");
    2836    try (InputStream in = website.openStream()) { Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING); }
    2937     */
    30    
     38
    3139    /*
    3240     * To do:
     
    3745
    3846    static byte[] header = {
    39         '0', '0', '2', '6', '2', '3', 'L', 'E', '1', ' ', '0', '9', '0', '0', '0', '7', '3', ' ', ' ', ' ', '6', '6', '0', '4', '0', '0', '0', '0', '0', '0', '0', '0',
    40         '1', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '4', '8', '0', '0', '0', '0', '1', '9', 'C', 'A', 'T', 'D', '0', '0', '0', '1',
    41         '2', '2', '0', '0', '0', '0', '6', '7', 0x1e, '0', '0', '0', '0', ';', '&', ' ', ' ', ' ', 0x1f, '0', '0', '0', '1', 'C', 'A', 'T', 'D', 0x1e, '0', '1', '0', '0',
    42         ';', '&', ' ', ' ', ' ', 'I', 'S', 'O', '/', 'I', 'E', 'C', ' ', '8', '2', '1', '1', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f',
    43         'i', 'e', 'r', 0x1f, 0x1f, '(', 'I', '(', '5', ')', ')', 0x1e, '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'C', 'a', 't', 'a', 'l', 'o', 'g', 'u', 'e', ' ', 'D',
    44         'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'F', 'I', 'L', 'E', '!', 'L', 'F',
    45         'I', 'L', '!', 'V', 'O', 'L', 'M', '!', 'I', 'M', 'P', 'L', '!', 'S', 'L', 'A', 'T', '!', 'W', 'L', 'O', 'N', '!', 'N', 'L', 'A', 'T', '!', 'E', 'L', 'O', 'N',
    46         '!', 'C', 'R', 'C', 'S', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'A', '(', '2', ')', ',', 'I', '(', '1', '0', ')', ',', '3', 'A', ',', 'A', '(', '3', ')', ',', '4',
    47         'R', ',', '2', 'A', ')', 0x1e,
    48         '0', '0', '1', '0', '1', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '5', '3', ' ', ' ', ' ', '5', '5', '0', '4',
    49         '0', '0', '0', '1', '0', '0', '0', '0', '6', '0', '0', '0', '0', '0',   'C', 'A', 'T', 'D', '0', '0', '0', '4', '2', '0', '0', '0', '0', '6', 0x1e,
    50         '0', '0', '0', '0', '0', 0x1e, 'C', 'D', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'C', 'A', 'T', 'A', 'L', 'O', 'G', '.', '0', '3', '1', 0x1f,
    51         0x1f, 'V', '0', '1', 'X', '0', '1', 0x1f, 'A', 'S', 'C', 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e
     47            // CHECKSTYLE.OFF: LineLength
     48            '0', '0', '2', '6', '2', '3', 'L', 'E', '1', ' ', '0', '9', '0', '0', '0', '7', '3', ' ', ' ', ' ', '6', '6', '0', '4', '0', '0', '0', '0', '0', '0', '0', '0',
     49            '1', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '4', '8', '0', '0', '0', '0', '1', '9', 'C', 'A', 'T', 'D', '0', '0', '0', '1',
     50            '2', '2', '0', '0', '0', '0', '6', '7', 0x1e, '0', '0', '0', '0', ';', '&', ' ', ' ', ' ', 0x1f, '0', '0', '0', '1', 'C', 'A', 'T', 'D', 0x1e, '0', '1', '0', '0',
     51            ';', '&', ' ', ' ', ' ', 'I', 'S', 'O', '/', 'I', 'E', 'C', ' ', '8', '2', '1', '1', ' ', 'R', 'e', 'c', 'o', 'r', 'd', ' ', 'I', 'd', 'e', 'n', 't', 'i', 'f',
     52            'i', 'e', 'r', 0x1f, 0x1f, '(', 'I', '(', '5', ')', ')', 0x1e, '1', '6', '0', '0', ';', '&', ' ', ' ', ' ', 'C', 'a', 't', 'a', 'l', 'o', 'g', 'u', 'e', ' ', 'D',
     53            'i', 'r', 'e', 'c', 't', 'o', 'r', 'y', ' ', 'F', 'i', 'e', 'l', 'd', 0x1f, 'R', 'C', 'N', 'M', '!', 'R', 'C', 'I', 'D', '!', 'F', 'I', 'L', 'E', '!', 'L', 'F',
     54            'I', 'L', '!', 'V', 'O', 'L', 'M', '!', 'I', 'M', 'P', 'L', '!', 'S', 'L', 'A', 'T', '!', 'W', 'L', 'O', 'N', '!', 'N', 'L', 'A', 'T', '!', 'E', 'L', 'O', 'N',
     55            '!', 'C', 'R', 'C', 'S', '!', 'C', 'O', 'M', 'T', 0x1f, '(', 'A', '(', '2', ')', ',', 'I', '(', '1', '0', ')', ',', '3', 'A', ',', 'A', '(', '3', ')', ',', '4',
     56            'R', ',', '2', 'A', ')', 0x1e,
     57            '0', '0', '1', '0', '1', ' ', 'D', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '5', '3', ' ', ' ', ' ', '5', '5', '0', '4',
     58            '0', '0', '0', '1', '0', '0', '0', '0', '6', '0', '0', '0', '0', '0', 'C', 'A', 'T', 'D', '0', '0', '0', '4', '2', '0', '0', '0', '0', '6', 0x1e,
     59            '0', '0', '0', '0', '0', 0x1e, 'C', 'D', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', 'C', 'A', 'T', 'A', 'L', 'O', 'G', '.', '0', '3', '1', 0x1f,
     60            0x1f, 'V', '0', '1', 'X', '0', '1', 0x1f, 'A', 'S', 'C', 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1e
     61            // CHECKSTYLE.ON: LineLength
    5262    };
    53    
     63
    5464    static BufferedReader in;
    5565    static FileOutputStream out;
     
    5969    static ArrayList<Fparams> fields;
    6070    static byte[] record;
    61    
     71
    6272    public static void main(String[] args) throws IOException {
    6373
    6474        map = new S57map(false);
    6575        int idx = 0;
    66        
     76
    6777        if (args.length < 4) {
    6878            System.err.println("Usage: java -jar josmtos57.jar OSM_filename meta_data_filename S57_ENC_ROOT_directory S57_filename");
     
    96106            System.exit(-1);
    97107        }
    98        
     108
    99109        try {
    100110            buf = new byte[5242880];
     
    107117            System.exit(-1);
    108118        }
    109        
     119
    110120        CRC32 crc = new CRC32();
    111121        crc.update(buf, 0, idx);
     
    120130        }
    121131        out.close();
    122        
     132
    123133        buf = new byte[header.length];
    124134        System.arraycopy(header, 0, buf, 0, header.length);
     
    126136        int recs = 2;
    127137        fields = new ArrayList<>();
    128         fields.add(new Fparams(S57field.CATD, new Object[]{ "CD", recs, args[3], "", "V01X01", "BIN", Math.toDegrees(map.bounds.minlat),
    129                 Math.toDegrees(map.bounds.minlon), Math.toDegrees(map.bounds.maxlat), Math.toDegrees(map.bounds.maxlon), String.format("%08X", crc.getValue()), "" }));
     138        fields.add(new Fparams(S57field.CATD, new Object[]{"CD", recs, args[3], "", "V01X01", "BIN", Math.toDegrees(map.bounds.minlat),
     139                Math.toDegrees(map.bounds.minlon), Math.toDegrees(map.bounds.maxlat), Math.toDegrees(map.bounds.maxlon),
     140                String.format("%08X", crc.getValue()), ""}));
    130141        record = S57dat.encRecord(String.valueOf(recs++), fields);
    131142        buf = Arrays.copyOf(buf, (buf.length + record.length));
     
    144155        out.close();
    145156
    146 //        String[] dir = (new File(args[2]).list());
    147 //        for (String item : dir) {
    148 //            System.err.println(item);
    149 //        }
    150        
     157        //        String[] dir = (new File(args[2]).list());
     158        //        for (String item : dir) {
     159        //            System.err.println(item);
     160        //        }
     161
    151162        System.err.println("Finished");
    152163    }
Note: See TracChangeset for help on using the changeset viewer.