diff --git a/src/osm/jp/postgis/Kml.java b/src/osm/jp/postgis/Kml.java
new file mode 100644
index 0000000..2b2eacc
--- /dev/null
+++ b/src/osm/jp/postgis/Kml.java
@@ -0,0 +1,341 @@
+package osm.jp.postgis;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.PipedWriter;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import javax.json.Json;
+import javax.json.JsonArray;
+import javax.json.JsonNumber;
+import javax.json.JsonObject;
+import javax.json.JsonReader;
+import javax.json.JsonValue;
+import jp.co.areaweb.tools.database.DatabaseTool;
+import osm.jp.api.Coverage;
+import osm.jp.api.Japan;
+import osm.jp.api.RectArea;
+
+public class Kml implements Runnable {
+ private ToPostgis type;
+ private final String name;
+ private final double lat;
+ private final double lon;
+ private final double km;
+
+ PipedWriter pipeOut;
+
+ public static final int MAX_DATA_COUNT = 1000;
+
+ /**
+ *
+ * @param pipeOut
+ * @param dbname
+ * @param name
+ * @param lat
+ * @param lon
+ * @param km
+ * @throws java.io.IOException
+ */
+ public Kml(PipedWriter pipeOut, String dbname, String name, double lat, double lon, double km) throws IOException {
+ this.name = name;
+ this.lat = lat;
+ this.lon = lon;
+ this.km = km;
+
+ this.type = null;
+ if (dbname.equals(osm.jp.coverage.busstop.DbBusstop.TABLE_NAME)) {
+ this.type = new osm.jp.coverage.busstop.ToPostgis();
+ }
+ else if (dbname.equals(osm.jp.coverage.fuel.DbFuel.TABLE_NAME)) {
+ this.type = new osm.jp.coverage.fuel.ToPostgis();
+ }
+ else if (dbname.equals(osm.jp.coverage.police.DbPolice.TABLE_NAME)) {
+ this.type = new osm.jp.coverage.police.ToPostgis();
+ }
+ else if (dbname.equals(osm.jp.coverage.postoffice.DbPostoffice.TABLE_NAME)) {
+ this.type = new osm.jp.coverage.postoffice.ToPostgis();
+ }
+
+ this.pipeOut = pipeOut;
+ }
+
+ @Override
+ @SuppressWarnings({"CallToPrintStackTrace", "SleepWhileInLoop"})
+ public void run() {
+ BufferedWriter bw = new BufferedWriter(pipeOut);
+ try (PrintWriter ow = new PrintWriter(bw))
+ {
+ ow.println("");
+ ow.println("");
+ ow.println("");
+ ow.flush();
+ try {
+ Thread.sleep(0);
+ }
+ catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ int count = 0;
+ try (Connection conPost = DatabaseTool.openDb(Coverage.DB_PORP_GISDB))
+ {
+ ow.println(getStringStyle());
+
+ ow.println(""+ name +"");
+ ow.println("1");
+ ow.println(getStringExtendedData(name));
+ ow.flush();
+ try {
+ Thread.sleep(0);
+ }
+ catch(InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ String sql = "SELECT area,gmlid,fixed,ST_Y(geom) AS lat, ST_X(geom) AS lon, ST_AsGeoJSON(ST_Transform(t_%s.geom,4326))::json As geometry "
+ + "FROM t_%s "
+ + "WHERE (ST_Y(geom) > ?) and (ST_Y(geom) < ?) and (ST_X(geom) > ?) and (ST_X(geom) < ?)";
+ sql = String.format(sql, type.tableName, type.tableName);
+ try (PreparedStatement ps8 = conPost.prepareStatement(sql)) {
+ RectArea rect = new RectArea(lat, lon, (int)(km * 2000));
+ ps8.setDouble(1, rect.minlat);
+ ps8.setDouble(2, rect.maxlat);
+ ps8.setDouble(3, rect.minlon);
+ ps8.setDouble(4, rect.maxlon);
+ try (ResultSet rset8 = ps8.executeQuery()) {
+ while (rset8.next()) {
+ String gmlid = rset8.getString("gmlid");
+ int area = rset8.getInt("area");
+ int fixed = rset8.getInt("fixed");
+
+ // geom: {"type":"Point","coordinates":[143.3147749,42.2984888]}
+ String geom = rset8.getString("geometry");
+ String lonStr = null;
+ String latStr = null;
+ try (JsonReader reader = Json.createReader(new StringReader(geom))) {
+ JsonObject geojson = reader.readObject();
+ JsonArray coordinates = geojson.getJsonArray("coordinates");
+ for (JsonValue v1 : coordinates) {
+ if (v1.getValueType() == JsonValue.ValueType.NUMBER) {
+ JsonNumber num = (JsonNumber)v1;
+ if (lonStr == null) {
+ lonStr = num.toString();
+ }
+ else {
+ latStr = num.toString();
+ }
+ }
+ }
+ }
+ if ((lonStr != null) && (latStr != null)) {
+ double lat0 = Double.parseDouble(latStr);
+ double lon0 = Double.parseDouble(lonStr);
+ double dd = Japan.distanceKm(lat,lon,lat0,lon0);
+ if (dd < km) {
+ count++;
+ if (count <= MAX_DATA_COUNT) {
+ String poiname = String.format("%02d - %s", area, gmlid);
+ String color = decideColor(fixed);
+ String str = getStringPlacemark(poiname, latStr, lonStr, color);
+ ow.println(str);
+ ow.flush();
+ try {
+ Thread.sleep(0);
+ }
+ catch(InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ else {
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ow.println("");
+ ow.println("");
+ ow.flush();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ String decideColor(int fixed) {
+ if (this.type instanceof osm.jp.coverage.busstop.ToPostgis) {
+ if (fixed == 0) {
+ return "red";
+ }
+ else if (fixed < 100) {
+ return "orange";
+ }
+ else {
+ return "green";
+ }
+ }
+ else if (this.type instanceof osm.jp.coverage.fuel.ToPostgis) {
+ if (fixed == 0) {
+ return "red";
+ }
+ else if (fixed < 50) {
+ return "orange";
+ }
+ else {
+ return "green";
+ }
+ }
+ else if (this.type instanceof osm.jp.coverage.police.ToPostgis) {
+ if (fixed == 0) {
+ return "red";
+ }
+ else {
+ return "green";
+ }
+ }
+ else if (this.type instanceof osm.jp.coverage.postoffice.ToPostgis) {
+ if (fixed == 0) {
+ return "red";
+ }
+ else {
+ return "green";
+ }
+ }
+ return "brown";
+ }
+
+ String getStringStyle() {
+ StringBuilder sbuf = new StringBuilder();
+ sbuf.append(icon("red"));
+ sbuf.append(icon("orange"));
+ sbuf.append(icon("green"));
+ sbuf.append(icon("brown"));
+ return sbuf.toString();
+ }
+
+ /**
+ *
+ * @param color ["red"|"blue"|"purple"|"yellow"|"pink"|"brown"|"green"|"orange"]
+ * @return
+ */
+ String icon(String color) {
+ StringBuilder sbuf = new StringBuilder();
+ sbuf.append(String.format("");
+ return sbuf.toString();
+ }
+
+ /**
+ *
+
+
+ poi
+
+
+
+ 2018-12-23T01:50:40Z
+ Local
+
+ *
+ *
+ */
+ String getStringExtendedData(String name) {
+ StringBuilder sbuf = new StringBuilder();
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append(name);
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append("");
+
+ sbuf.append("");
+ sbuf.append((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")).format(new Date()));
+ sbuf.append("");
+
+ sbuf.append("Local");
+ sbuf.append("");
+ return sbuf.toString();
+ }
+
+ /**
+ *
+
+ 新日本海フェリー 苫小牧東港ターミナル
+ 2017-12-28T11:15:56Z
+ #placemark-blue
+ 141.81955,42.610008
+
+
+ 新日本海フェリー 苫小牧東港ターミナル
+
+
+
+
+ 新日本海フェリー 苫小牧東港ターミナル
+
+ 13
+
+
+ *
+ */
+ String getStringPlacemark(String name, String latStr, String lonStr, String color) {
+ StringBuilder sbuf = new StringBuilder();
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append(name);
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")).format(new Date()));
+ sbuf.append("");
+ sbuf.append(String.format("#placemark-%s", color));
+ sbuf.append("");
+ sbuf.append(String.format("%s,%s", lonStr, latStr));
+ sbuf.append("");
+ sbuf.append(getStringPlacemarkExtendedData(name));
+ sbuf.append("");
+ return sbuf.toString();
+ }
+
+ /**
+ *
+
+
+ 新日本海フェリー 苫小牧東港ターミナル
+
+
+
+
+ 新日本海フェリー 苫小牧東港ターミナル
+
+ 13
+
+ *
+ */
+ String getStringPlacemarkExtendedData(String name) {
+ StringBuilder sbuf = new StringBuilder();
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append(name);
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append("");
+ sbuf.append(name);
+ sbuf.append("");
+ sbuf.append("13");
+ sbuf.append("");
+ return sbuf.toString();
+ }
+}
diff --git a/src/osm/jp/postgis/Kmz.java b/src/osm/jp/postgis/Kmz.java
new file mode 100644
index 0000000..9d2bde6
--- /dev/null
+++ b/src/osm/jp/postgis/Kmz.java
@@ -0,0 +1,40 @@
+package osm.jp.postgis;
+
+import java.io.ByteArrayInputStream;
+import java.io.OutputStream;
+import org.apache.commons.compress.archivers.ArchiveOutputStream;
+import org.apache.commons.compress.archivers.ArchiveStreamFactory;
+import org.apache.commons.compress.utils.IOUtils;
+
+public class Kmz implements Runnable {
+ ByteArrayInputStream in;
+ OutputStream out;
+
+ public Kmz(ByteArrayInputStream in, OutputStream out) {
+ this.in = in;
+ this.out = out;
+ }
+
+ @Override
+ @SuppressWarnings({"CallToPrintStackTrace", "null", "UseSpecificCatch"})
+ public void run() {
+ try {
+ int data = in.read();
+ while (data != -1) {
+ System.out.print((char) data);
+ data = in.read();
+ }
+ /*
+ try {
+ ArchiveOutputStream os = new ArchiveStreamFactory().createArchiveOutputStream(ArchiveStreamFactory.ZIP, out);
+ IOUtils.copy(in, os);
+ os.closeArchiveEntry();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ */
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/src/osm/jp/postgis/PipeConverter.java b/src/osm/jp/postgis/PipeConverter.java
new file mode 100644
index 0000000..b2c0b36
--- /dev/null
+++ b/src/osm/jp/postgis/PipeConverter.java
@@ -0,0 +1,31 @@
+package osm.jp.postgis;
+
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+import java.io.PipedReader;
+
+public class PipeConverter implements Runnable {
+ PipedReader source;
+ ByteArrayOutputStream out;
+
+ public PipeConverter(PipedReader source, ByteArrayOutputStream out) {
+ this.source = source;
+ this.out = out;
+ }
+
+ @Override
+ @SuppressWarnings("CallToPrintStackTrace")
+ public void run() {
+ try {
+ int data = source.read();
+ while (data != -1) {
+ out.write(data);
+ data = source.read();
+ }
+ out.flush();
+ out.close();
+ } catch (IOException ex) {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/src/osm/jp/postgis/UnMapped.java b/src/osm/jp/postgis/UnMapped.java
index 87c6d80..956d46e 100644
--- a/src/osm/jp/postgis/UnMapped.java
+++ b/src/osm/jp/postgis/UnMapped.java
@@ -1,359 +1,74 @@
package osm.jp.postgis;
-import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.StringReader;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-import javax.json.JsonValue;
-import javax.xml.parsers.ParserConfigurationException;
-import jp.co.areaweb.tools.database.DatabaseTool;
-import org.apache.commons.compress.archivers.ArchiveException;
-import org.xml.sax.SAXException;
-import osm.jp.api.Coverage;
-import osm.jp.api.Japan;
-import tools.Compless;
+import java.io.OutputStream;
+import java.io.PipedReader;
+import java.io.PipedWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.commons.compress.archivers.ArchiveOutputStream;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+import org.apache.commons.compress.utils.IOUtils;
public class UnMapped {
ToPostgis type;
String dbname;
- public static final int MAX_DATA_COUNT = 300;
@SuppressWarnings({"UseSpecificCatch", "CallToPrintStackTrace"})
public static void main(String[] args) {
+ String dbname = "busstop";
+ (new UnMapped(dbname)).createKml(35.4341254D,139.408969D, 3.0D);
+ }
+
+ public UnMapped(String dbname) {
+ this.dbname = dbname;
+ }
+
+ @SuppressWarnings({"CallToPrintStackTrace", "UseSpecificCatch"})
+ public void createKml(double lat, double lon, double km) {
try {
- File kmz = (new UnMapped("busstop"))
- .getKmz(35.4341254D,139.408969D, 3.0D);
+ final PipedReader read = new PipedReader();
+ final PipedWriter write = new PipedWriter(read);
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
+ String title = "'"+ dbname +"' - UnMapped OpenSteetMap";
+
+ Thread kml = new Thread(new Kml(write, dbname, title, lat,lon, km));
+ Thread converter = new Thread(new PipeConverter(read, out));
+
+ kml.start();
+ converter.start();
+ try {
+ kml.join();
+ converter.join();
+ }
+ catch(InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ File kmzFile = new File(dbname +".kmz");
+ File kmlFile = new File(dbname +".kml");
+ try {
+ try (OutputStream outKmz = Files.newOutputStream(Paths.get(kmzFile.getName()));
+ ArchiveOutputStream o = new ZipArchiveOutputStream(outKmz))
+ {
+ ArchiveEntry entry = o.createArchiveEntry(kmlFile, kmlFile.getName());
+ o.putArchiveEntry(entry);
+ try (ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray())) {
+ IOUtils.copy(in, o);
+ }
+ o.closeArchiveEntry();
+ }
+ }
+ finally {
+ out.flush();
+ out.close();
+ }
}
catch(Exception e) {
e.printStackTrace();
}
}
-
- /**
- * コンストラクタ
- * @param dbname
- * @throws java.lang.ClassNotFoundException
- * @throws java.sql.SQLException
- * @throws java.io.IOException
- */
- public UnMapped(String dbname) throws ClassNotFoundException, SQLException, IOException {
- this.type = null;
- this.dbname = dbname;
- if (dbname.equals(osm.jp.coverage.busstop.DbBusstop.TABLE_NAME)) {
- this.type = new osm.jp.coverage.busstop.ToPostgis();
- }
- else if (dbname.equals(osm.jp.coverage.fuel.DbFuel.TABLE_NAME)) {
- this.type = new osm.jp.coverage.fuel.ToPostgis();
- }
- else if (dbname.equals(osm.jp.coverage.police.DbPolice.TABLE_NAME)) {
- this.type = new osm.jp.coverage.police.ToPostgis();
- }
- else if (dbname.equals(osm.jp.coverage.postoffice.DbPostoffice.TABLE_NAME)) {
- this.type = new osm.jp.coverage.postoffice.ToPostgis();
- }
- }
-
- /**
- *
- * @param lat0 緯度
- * @param lon0 経度
- * @param km 半径(km)
- * @return KMZファイル
- * @throws java.lang.ClassNotFoundException
- * @throws java.sql.SQLException
- * @throws java.io.IOException
- * @throws java.io.FileNotFoundException
- * @throws javax.xml.parsers.ParserConfigurationException
- * @throws org.xml.sax.SAXException
- * @throws org.apache.commons.compress.archivers.ArchiveException
- */
- public File getKmz(double lat0, double lon0, double km) throws ClassNotFoundException, SQLException, IOException, FileNotFoundException, ParserConfigurationException, SAXException, ArchiveException {
- File kml = new File(dbname +".kml");
- File kmz = new File(dbname +".kmz");
- toKml(kml, "'"+ this.dbname +"' - UnMapped OpenSteetMap", 35.4341254D,139.408969D,3.0D);
- toKmz(kml, kmz);
- kml.delete();
- return kmz;
- }
-
- public UnMapped toKmz(File kml, File kmz) throws ArchiveException, IOException {
- Compless.toZip(kml, kmz);
- return this;
- }
-
- /**
- *
- * @param kmlFile
- * @param name
- * @param lat0
- * @param lon0
- * @param km
- * @return
- * @throws FileNotFoundException
- * @throws ClassNotFoundException
- * @throws SQLException
- * @throws IOException
- * @throws ParserConfigurationException
- * @throws SAXException
- */
- public UnMapped toKml (File kmlFile, String name, double lat0, double lon0, double km)
- throws FileNotFoundException, ClassNotFoundException, SQLException, IOException, ParserConfigurationException, SAXException
- {
- int count = 0;
- try (Connection conPost = DatabaseTool.openDb(Coverage.DB_PORP_GISDB);
- BufferedWriter ow = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(kmlFile), "UTF-8")))
- {
- ow.write("");
- ow.newLine();
- ow.write("");
- ow.newLine();
- ow.write("");
- ow.newLine();
- {
- ow.write(getStringStyle());
- ow.newLine();
-
- ow.write(""+ name +"");
- ow.newLine();
- ow.write("1");
- ow.newLine();
- ow.write(getStringExtendedData(name));
- ow.newLine();
-
- String sql = "SELECT area,gmlid,fixed,ST_AsGeoJSON(ST_Transform(t_%s.geom,4326))::json As geometry FROM t_%s";
- sql = String.format(sql, type.tableName, type.tableName);
- try (PreparedStatement ps8 = conPost.prepareStatement(sql)) {
- try (ResultSet rset8 = ps8.executeQuery()) {
- while (rset8.next()) {
- String gmlid = rset8.getString("gmlid");
- int area = rset8.getInt("area");
- int fixed = rset8.getInt("fixed");
-
- // geom: {"type":"Point","coordinates":[143.3147749,42.2984888]}
- String geom = rset8.getString("geometry");
- String lonStr = null;
- String latStr = null;
- try (JsonReader reader = Json.createReader(new StringReader(geom))) {
- JsonObject geojson = reader.readObject();
- JsonArray coordinates = geojson.getJsonArray("coordinates");
- for (JsonValue v1 : coordinates) {
- if (v1.getValueType() == JsonValue.ValueType.NUMBER) {
- JsonNumber num = (JsonNumber)v1;
- if (lonStr == null) {
- lonStr = num.toString();
- }
- else {
- latStr = num.toString();
- }
- }
- }
- }
- if ((lonStr != null) && (latStr != null)) {
- double lat = Double.parseDouble(latStr);
- double lon = Double.parseDouble(lonStr);
- double dd = Japan.distanceKm(lat0,lon0,lat,lon);
- if (dd < km) {
- count++;
- if (count <= MAX_DATA_COUNT) {
- String poiname = String.format("%02d - %s", area, gmlid);
- String color = decideColor(fixed);
- ow.write(getStringPlacemark(poiname, latStr, lonStr, color));
- ow.newLine();
- }
- }
- }
- }
- }
- }
- }
- ow.write("");
- ow.write("");
- ow.flush();
- }
- return this;
- }
-
- String decideColor(int fixed) {
- if (this.type instanceof osm.jp.coverage.busstop.ToPostgis) {
- if (fixed == 0) {
- return "red";
- }
- else if (fixed < 100) {
- return "orange";
- }
- else {
- return "green";
- }
- }
- else if (this.type instanceof osm.jp.coverage.fuel.ToPostgis) {
- if (fixed == 0) {
- return "red";
- }
- else if (fixed < 50) {
- return "orange";
- }
- else {
- return "green";
- }
- }
- else if (this.type instanceof osm.jp.coverage.police.ToPostgis) {
- if (fixed == 0) {
- return "red";
- }
- else {
- return "green";
- }
- }
- else if (this.type instanceof osm.jp.coverage.postoffice.ToPostgis) {
- if (fixed == 0) {
- return "red";
- }
- else {
- return "green";
- }
- }
- return "brown";
- }
-
- String getStringStyle() {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append(icon("red"));
- sbuf.append(icon("orange"));
- sbuf.append(icon("green"));
- sbuf.append(icon("brown"));
- return sbuf.toString();
- }
-
- /**
- *
- * @param color ["red"|"blue"|"purple"|"yellow"|"pink"|"brown"|"green"|"orange"]
- * @return
- */
- String icon(String color) {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append(String.format("");
- return sbuf.toString();
- }
-
- /**
- *
-
-
- poi
-
-
-
- 2018-12-23T01:50:40Z
- Local
-
- *
- *
- */
- String getStringExtendedData(String name) {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("");
- sbuf.append("");
- sbuf.append(name);
- sbuf.append("");
- sbuf.append("");
- sbuf.append("");
-
- sbuf.append("");
- sbuf.append((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")).format(new Date()));
- sbuf.append("");
-
- sbuf.append("Local");
- sbuf.append("");
- return sbuf.toString();
- }
-
- /**
- *
-
- 新日本海フェリー 苫小牧東港ターミナル
- 2017-12-28T11:15:56Z
- #placemark-blue
- 141.81955,42.610008
-
-
- 新日本海フェリー 苫小牧東港ターミナル
-
-
-
-
- 新日本海フェリー 苫小牧東港ターミナル
-
- 13
-
-
- *
- */
- String getStringPlacemark(String name, String latStr, String lonStr, String color) {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("");
- sbuf.append("");
- sbuf.append(name);
- sbuf.append("");
- sbuf.append("");
- sbuf.append((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ")).format(new Date()));
- sbuf.append("");
- sbuf.append(String.format("#placemark-%s", color));
- sbuf.append("");
- sbuf.append(String.format("%s,%s", lonStr, latStr));
- sbuf.append("");
- sbuf.append(getStringPlacemarkExtendedData(name));
- sbuf.append("");
- return sbuf.toString();
- }
-
- /**
- *
-
-
- 新日本海フェリー 苫小牧東港ターミナル
-
-
-
-
- 新日本海フェリー 苫小牧東港ターミナル
-
- 13
-
- *
- */
- String getStringPlacemarkExtendedData(String name) {
- StringBuilder sbuf = new StringBuilder();
- sbuf.append("");
- sbuf.append("");
- sbuf.append(name);
- sbuf.append("");
- sbuf.append("");
- sbuf.append("");
- sbuf.append(name);
- sbuf.append("");
- sbuf.append("13");
- sbuf.append("");
- return sbuf.toString();
- }
-
}
diff --git a/src/tools/ExIO3.java b/src/tools/ExIO3.java
new file mode 100644
index 0000000..c38c5b8
--- /dev/null
+++ b/src/tools/ExIO3.java
@@ -0,0 +1,72 @@
+package tools;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PipedReader;
+import java.io.PipedWriter;
+import java.io.PrintWriter;
+import java.io.Reader;
+
+public class ExIO3 {
+ public static void main(String[] args) throws IOException {
+ ExIO3 object1 = new ExIO3();
+ object1.sortValue(object1.getValue());
+ }
+
+ Reader getValue () throws IOException {
+ FileReader csv = new FileReader("sales.csv");
+ BufferedReader in = new BufferedReader(csv);
+
+ PipedWriter pipeOut = new PipedWriter();
+ PipedReader pipeIn = new PipedReader(pipeOut);
+ PrintWriter out = new PrintWriter(pipeOut);
+
+ String line;
+ String[] arrayline;
+
+ //(8)読み込みソースがなくなるまで読み込み、
+ // 読み込みデータをprintlnメソッドで書き込み
+ while((line = in.readLine()) != null) {
+ arrayline = line.split(",");
+ out.println(arrayline[3]);
+ out.flush();
+ }
+
+ in.close(); //(9)読み込みストリームのクローズ
+ out.close(); //(10)書き込みストリームのクローズ
+
+ return pipeIn; //(11)pipeInオブジェクトのリターン
+ }
+
+ void sortValue(Reader source) throws IOException {
+ BufferedReader in = new BufferedReader(source);
+
+ String line; String[] data = new String[5];
+ int m = 0;
+ int price1, price2;
+
+ while ((line = in.readLine()) != null) {
+ data[m] = line;
+ m++;
+ }
+
+ //(14)売上データをソート
+ for (int i = 0; i < data.length - 1; i++) {
+ for (int j = data.length - 1; j > i; j--) {
+ price1 = Integer.parseInt(data[j]);
+ price2 = Integer.parseInt(data[j-1]);
+ if (price1 > price2) {
+ String temp = data[j];
+ data[j] = data[j-1];
+ data[j-1] = temp;
+ }
+ }
+ }
+
+ for (int k = 0; k < data.length; k++) {
+ System.out.println(data[k]);
+ }
+ in.close(); //(16)読み込みストリームのクローズ
+ }
+}
diff --git a/test/busstop.kmz b/test/busstop.kmz
new file mode 100644
index 0000000..30e8330
--- /dev/null
+++ b/test/busstop.kmz
Binary files differ
diff --git a/test/osm/jp/postgis/UnMappedTest.java b/test/osm/jp/postgis/UnMappedTest.java
index 08caca5..98090de 100644
--- a/test/osm/jp/postgis/UnMappedTest.java
+++ b/test/osm/jp/postgis/UnMappedTest.java
@@ -6,8 +6,6 @@
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.helpers.DefaultHandler;
import jp.co.areaweb.tools.database.DatabaseTool;
import static org.hamcrest.CoreMatchers.is;
@@ -102,8 +100,7 @@
void check(String dbname) {
File kmz = null;
try {
- kmz = (new UnMapped(dbname))
- .getKmz(35.4341254D,139.408969D, 5.0D);
+ (new UnMapped(dbname)).createKml(35.4341254D,139.408969D, 5.0D);
}
catch(Exception e) {
fail(e.toString());
diff --git a/test/sales.csv b/test/sales.csv
new file mode 100644
index 0000000..ce0eefb
--- /dev/null
+++ b/test/sales.csv
@@ -0,0 +1,5 @@
+2002/10/10,洗濯機,SHARP,100
+2002/10/10,掃除機,MITHUBISHI,200
+2002/10/10,乾燥機,HITACHI,50
+2002/10/10,テレビ,SONY,600
+2002/10/10,DVDプレーヤー,KENWOOD,300
\ No newline at end of file