Ticket #23157: seachart.diff

File seachart.diff, 3.3 KB (added by oobayly, 3 years ago)
  • seachart/jrenderpgsql/src/jrenderpgsql/JrenderPgsql.java

    diff --git a/seachart/jrenderpgsql/src/jrenderpgsql/JrenderPgsql.java b/seachart/jrenderpgsql/src/jrenderpgsql/JrenderPgsql.java
    index 0040df3..02d270a 100644
    a b import java.awt.Graphics2D;  
    66import java.awt.Rectangle;
    77import java.awt.geom.Point2D;
    88import java.awt.image.BufferedImage;
    9 import java.io.BufferedReader;
     9import java.io.ByteArrayInputStream;
    1010import java.io.StringReader;
    1111import java.io.ByteArrayOutputStream;
    1212import java.io.FileOutputStream;
     13import java.nio.charset.StandardCharsets;
    1314import java.util.ArrayList;
    1415import java.util.HashMap;
    1516
    public final class JrenderPgsql {  
    395396        // The pseudo OSM file is now complete, and we feed it to the S57
    396397        // library where it will be parsed again.
    397398
    398         BufferedReader in = new BufferedReader(new StringReader(combinedBuf.toString()));
     399        ByteArrayInputStream in = new ByteArrayInputStream(combinedBuf.toString().getBytes(StandardCharsets.UTF_8));
    399400        map = new S57map(true);
    400401        S57osm.OSMmap(in, map, false);
    401402        in.close();
    public final class JrenderPgsql {  
    427428            public RuleSet ruleset() {
    428429                return RuleSet.SEAMARK;
    429430            }
     431
     432            public Chart chart() {
     433              return null;
     434            }
     435
     436            public int grid() {
     437              return 0;
     438            }
    430439        };
    431440
    432441        // invoke renderer, and write file to disk
  • seachart/src/s57/S57osm.java

    diff --git a/seachart/src/s57/S57osm.java b/seachart/src/s57/S57osm.java
    index 839f34e..0f50583 100644
    a b  
    22package s57;
    33
    44import java.io.File;
     5import java.io.InputStream;
     6import java.io.FileInputStream;
    57import java.util.ArrayList;
    68import java.util.HashMap;
    79
    public final class S57osm { // OSM to S57 Object/Attribute and Object/Primitive  
    9799        return;
    98100    }
    99101
    100     public static void OSMmap(File in, S57map map, boolean bb) throws Exception {
     102    public static void OSMmap(File file, S57map map, boolean bb) throws Exception {
     103        try (InputStream in = new FileInputStream(file)) {
     104          OSMmap(in, map, bb);
     105        }
     106    }
     107
     108    public static void OSMmap(InputStream in, S57map map, boolean bb) throws Exception {
     109        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
     110        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
     111        Document doc = dBuilder.parse(in);
     112
     113        OSMmap(doc, map, bb);
     114    }
     115
     116    public static void OSMmap(Document doc, S57map map, boolean bb) throws Exception {
    101117        double lat = 0;
    102118        double lon = 0;
    103119        long id = 0;
    public final class S57osm { // OSM to S57 Object/Attribute and Object/Primitive  
    112128        map.nodes.put(3L, new Snode());
    113129        map.nodes.put(4L, new Snode());
    114130
    115         DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    116         DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
    117         Document doc = dBuilder.parse(in);
    118131        doc.getDocumentElement().normalize();
    119132        if (!doc.getDocumentElement().getNodeName().equals("osm")) {
    120133            System.err.println("OSM file format error");