• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqtwindows誰得cocoapythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdomvb.netdirectxbtronarduinopreviewerゲームエンジン

Commit MetaInfo

Revisión271b154108a319d24c3003603cdff5c73b9e2765 (tree)
Tiempo2012-07-16 10:10:39
Autorunknown <yuu@c56n...>
Commiterunknown

Log Message

AdmPt25000 Wiki text

Cambiar Resumen

Diferencia incremental

--- a/dest/ConvAdmPt25000.bat
+++ /dev/null
@@ -1,3 +0,0 @@
1-rem java -jar OsmConverter.jar ConvAdmPt25000 -link
2-java -jar OsmConverter.jar ConvAdmPt25000 -nolink
3-pause
\ No newline at end of file
--- a/src/hayashi/kiban/ConvAdmPt25000.java
+++ b/src/hayashi/kiban/ConvAdmPt25000.java
@@ -1,9 +1,29 @@
11 package hayashi.kiban;
2+import hayashi.osm.api.Command;
3+
24 import javax.xml.parsers.*;
35 import org.w3c.dom.*;
46 import org.xml.sax.*;
57 import java.io.*;
68
9+/**
10+ * ====基盤地図情報のダウンロード====
11+ *
12+ * まず最初に、基盤地図情報をダウンロードします。
13+ *
14+ * 国土地理院の基盤地図情報ダウンロードページから、ログイン画面へ進みログインして、「基盤地図情報 縮尺レベル25000 JPGIS形式」を選択し、対象の地域のファイルをダウンロードします。(「JPGIS(GML)形式」ではありません)
15+ * http://fgd.gsi.go.jp/download/
16+ *
17+ * 対象地域と項目の選択方法は、ダウンロードページの指示に従ってください。
18+ *
19+ * 「基盤地図情報項目」では「行政区画の境界線及び代表点」を選択してください。
20+ * 「FG-JPS-39-05-Z001.zip」というような「FG-JPS-xx-05-Z001.zip」という形式のZIPファイルがダウンロードされます。
21+ *
22+ * ダウンロードした圧縮ファイルを解凍しておきます。
23+ * 解凍すると「FG-JPS-44209-CommBdry-20091109-0001.xml」というような「FG-JPS-xxxx-CommBdry-xxxxxxxx-xxxx.xml」という形式のXMLファイルが出来上がります。
24+ * @author yuu
25+ *
26+ */
727 public class ConvAdmPt25000 {
828 File inputFile;
929 String admCodeStr = "";
@@ -104,11 +124,9 @@ public class ConvAdmPt25000 {
104124
105125 File outputFile = new File(iStr.substring(0, iStr.length() - 4) +".gpx");
106126 BufferedWriter w = null;
107- System.out.println(outputFile.getName() + " => ");
108127
109128 File htmlFile = new File(iStr.substring(0, iStr.length() - 4) +".html");
110129 BufferedWriter hw = null;
111- System.out.println(htmlFile.getName() + " => ");
112130
113131 try {
114132 w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8"));
@@ -117,6 +135,16 @@ public class ConvAdmPt25000 {
117135 w.write("<gpx xmlns=\"http://www.topografix.com/GPX/1/1\" version=\"1.1\" creator=\"osmtracker-android\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd \">");
118136 w.newLine();
119137
138+ System.out.println("=== "+ admCodeStr +": "+ Command.getCodeName(Integer.parseInt(admCodeStr)) +" ===");
139+ System.out.println("{| class=\"wikitable sortable\"");
140+
141+ System.out.println("|- ");
142+ System.out.println("! style=\"width:70px\" | admCode");
143+ System.out.println("! | name");
144+ System.out.println("! style=\"width:70px\" | type");
145+ System.out.println("! | 備考/最終更新日");
146+
147+
120148 hw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(htmlFile), "UTF-8"));
121149 hw.write("<!DOCTYPE html>");
122150 hw.newLine();
@@ -125,7 +153,6 @@ public class ConvAdmPt25000 {
125153 hw.write("<body><table border='1'>");
126154 hw.newLine();
127155 hw.write("<tr>");
128- hw.write("<td></td>");
129156 hw.write("<td>admCode</td>");
130157 hw.write("<td>name</td>");
131158 hw.write("<td></td>");
@@ -146,6 +173,9 @@ public class ConvAdmPt25000 {
146173
147174 hw.write("</table></body></html>");
148175 hw.newLine();
176+
177+ System.out.println("|}");
178+
149179 } catch (ParserConfigurationException e0) {
150180 System.out.println(e0.getMessage());
151181 } catch (SAXException e1){
@@ -154,7 +184,6 @@ public class ConvAdmPt25000 {
154184 System.out.println(e2.getMessage());
155185 }
156186 finally {
157- System.out.println("地名数["+ iCounter +"]");
158187 if (w != null) {
159188 try {
160189 w.close();
@@ -168,11 +197,12 @@ public class ConvAdmPt25000 {
168197 }
169198
170199 public void showNodes(BufferedWriter w, BufferedWriter hw, Node node, String space) throws IOException {
200+ String codeStr_ = "";
171201 NodeList nodes = node.getChildNodes();
172202 for (int i=0; i<nodes.getLength(); i++) {
173203 Node node2 = nodes.item(i);
174204 if (node2.getNodeName().equals("AdmPt")) {
175- showAdmPt(w, hw, node2);
205+ codeStr_ = showAdmPt(w, hw, node2, codeStr_);
176206 }
177207 else {
178208 showNodes(w, hw, node2, space + " ");
@@ -180,28 +210,26 @@ public class ConvAdmPt25000 {
180210 }
181211 }
182212
183- public void showAdmPt(BufferedWriter w, BufferedWriter hw, Node node) throws IOException {
213+ public String showAdmPt(BufferedWriter w, BufferedWriter hw, Node node, String codeStr_) throws IOException {
184214 String positionStr = "";
185215 String typeStr = "";
186216 String nameStr = "";
187217 String latStr = "";
188218 String lonStr = "";
189219 String dateStr = "";
190- String idStr = "";
191220 String codeStr = "";
192221
193222 NodeList nodes = node.getChildNodes();
194- NamedNodeMap nodeMap = node.getAttributes();
195- if ( null != nodeMap ) {
196- for ( int j=0; j<nodeMap.getLength(); j++ ) {
197- if (nodeMap.item(j).getNodeName().equals("id")) {
198- idStr = nodeMap.item(j).getNodeValue();
199- }
200- }
201- }
202223 for (int i=0; i < nodes.getLength(); i++) {
203224 Node node2 = nodes.item(i);
204- if (node2.getNodeName().equals("pos")) {
225+ if (node2.getNodeName().equals("admCode")) {
226+ codeStr = node2.getTextContent();
227+ if (codeStr.trim().equals(codeStr_.trim())) {
228+ return codeStr;
229+ }
230+ codeStr_ = new String(codeStr);
231+ }
232+ else if (node2.getNodeName().equals("pos")) {
205233 NodeList nodes3 = node2.getChildNodes();
206234 for (int j=0; j < nodes3.getLength(); j++) {
207235 Node node3 = nodes3.item(j);
@@ -241,66 +269,31 @@ public class ConvAdmPt25000 {
241269 else if (node2.getNodeName().equals("name")) {
242270 nameStr = node2.getTextContent();
243271 }
244- else if (node2.getNodeName().equals("admCode")) {
245- codeStr = node2.getTextContent();
246- }
247272 }
248273
249- String oName = "FG-JPS-"+ codeStr +"-AdmPt25000-"+ idStr +".txt";
250- if (link) {
251- this.iCounter++;
252- File o2File = new File(oName);
253- BufferedWriter w2 = null;
254- try {
255- w2 = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(o2File), "UTF-8"));
256- w2.write("name="+ nameStr +"");
257- w2.newLine();
258- w2.write("type:"+ typeStr);
259- w2.newLine();
260- w2.write("admCode:"+ codeStr);
261- w2.newLine();
262- w2.write("date:"+ dateStr);
263- w2.newLine();
264- w2.write("id:"+ idStr);
265- w2.newLine();
266- w2.write("source=GSI/KIBAN Block http://wiki.osm.org/wiki/GSI_KIBAN");
267- w2.newLine();
268- System.out.println(idStr +","+ codeStr +","+ nameStr +","+ typeStr);
269- }
270- finally {
271- if (w2 != null) {
272- try {
273- w2.close();
274- }
275- catch (IOException e) {
276- e.printStackTrace();
277- }
278- }
279- }
280- }
274+ System.out.println("|- ");
275+ System.out.println("| " + codeStr);
276+ System.out.println("| " + nameStr);
277+ System.out.println("| " + typeStr);
278+ System.out.println("| ");
281279
282- hw.write("<td>"+ idStr +"</td>");
280+ hw.write("<tr>");
283281 hw.write("<td>"+ codeStr +"</td>");
284282 hw.write("<td>"+ nameStr +"</td>");
285283 hw.write("<td>"+ typeStr +"</td>");
286284 hw.write("</tr>");
287285 hw.newLine();
288286
289- //System.out.println(admCodeStr +","+ typeStr +","+ nameStr +","+ latStr +","+ lonStr +","+ dateStr);
290287 w.write("<wpt lat=\""+ latStr +"\" lon=\""+ lonStr +"\">");
291288 w.newLine();
292289 w.write(" <time>"+ dateStr +"T00:00:00Z</time>");
293290 w.newLine();
294291 w.write(" <name><![CDATA["+ nameStr +"]]></name>");
295292 w.newLine();
296-
297- if (link) {
298- w.write(" <link href=\""+ oName +"\"><text>"+ nameStr +"</text></link>");
299- w.newLine();
300- }
301-
302293 w.write("</wpt>");
303294 w.newLine();
295+
296+ return codeStr;
304297 }
305298
306299 /**
--- a/src/hayashi/osm/api/Command.java
+++ b/src/hayashi/osm/api/Command.java
@@ -81,6 +81,106 @@ public class Command {
8181 System.out.println("\t ConvBusstopGML : ");
8282 }
8383
84+ public static String getCodeName(int code) {
85+ switch (code) {
86+ case 1:
87+ return "北海道";
88+ case 2:
89+ return "青森県";
90+ case 3:
91+ return "岩手県";
92+ case 4:
93+ return "宮城県";
94+ case 5:
95+ return "秋田県";
96+ case 6:
97+ return "山形県";
98+ case 7:
99+ return "福島県";
100+ case 8:
101+ return "茨城県";
102+ case 9:
103+ return "栃木県";
104+ case 10:
105+ return "群馬県";
106+ case 11:
107+ return "埼玉県";
108+ case 12:
109+ return "千葉県";
110+ case 13:
111+ return "東京都";
112+ case 14:
113+ return "神奈川県";
114+ case 15:
115+ return "新潟県";
116+ case 16:
117+ return "富山県";
118+ case 17:
119+ return "石川県";
120+ case 18:
121+ return "福井県";
122+ case 19:
123+ return "山梨県";
124+ case 20:
125+ return "長野県";
126+ case 21:
127+ return "岐阜県";
128+ case 22:
129+ return "静岡県";
130+ case 23:
131+ return "愛知県";
132+ case 24:
133+ return "三重県";
134+ case 25:
135+ return "滋賀県";
136+ case 26:
137+ return "京都府";
138+ case 27:
139+ return "大阪府";
140+ case 28:
141+ return "兵庫県";
142+ case 29:
143+ return "奈良県";
144+ case 30:
145+ return "和歌山";
146+ case 31:
147+ return "鳥取県";
148+ case 32:
149+ return "島根県";
150+ case 33:
151+ return "岡山県";
152+ case 34:
153+ return "広島県";
154+ case 35:
155+ return "山口県";
156+ case 36:
157+ return "徳島県";
158+ case 37:
159+ return "香川県";
160+ case 38:
161+ return "愛媛県";
162+ case 39:
163+ return "高知県";
164+ case 40:
165+ return "福岡県";
166+ case 41:
167+ return "佐賀県";
168+ case 42:
169+ return "長崎県";
170+ case 43:
171+ return "熊本県";
172+ case 44:
173+ return "大分県";
174+ case 45:
175+ return "宮崎県";
176+ case 46:
177+ return "鹿児島";
178+ case 47:
179+ return "沖縄県";
180+ }
181+ return "";
182+ }
183+
84184 static String[] shiftArgs(String[] args) {
85185 String[] values = new String[args.length - 1];
86186 for (int i=1; i < args.length; i++) {