• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

巨大森林を分割する


Commit MetaInfo

Révisionef1cf628906f00ee0943f393458a628e82c1e8b0 (tree)
l'heure2013-10-29 08:45:32
Auteurhayashi.yuu <hayashi.yuu@gmai...>
Commiterhayashi.yuu

Message de Log

WAYの接続を改良

Change Summary

Modification

--- /dev/null
+++ b/src/hsqlmanager.sh
@@ -0,0 +1,3 @@
1+#!/bin/sh
2+cd database
3+java -cp .:../../hsqldb.jar org.hsqldb.util.DatabaseManagerSwing
\ No newline at end of file
--- a/src/osm/jp/DbBigrelation.java
+++ b/src/osm/jp/DbBigrelation.java
@@ -404,6 +404,37 @@ public class DbBigrelation
404404 ps6.executeUpdate();
405405 ps6.close();
406406 }
407+
408+ /**
409+ * WAYを接続する
410+ * @param addway
411+ * @throws SQLException
412+ */
413+ public static void connect_WAY(Connection con, long firstwayid, long secondwayid) throws SQLException {
414+ PreparedStatement ps1 = con.prepareStatement("select max(CNT) from NDREF where (idref = ?)");
415+ ps1.setLong(1, firstwayid);
416+ ResultSet rset1 = ps1.executeQuery();
417+ if (rset1.next()) {
418+ double firstcnt = rset1.getDouble(1);
419+
420+ PreparedStatement ps2 = con.prepareStatement("select * from NDREF where (idref = ?)");
421+ ps2.setLong(1, secondwayid);
422+ ResultSet rset2 = ps2.executeQuery();
423+ while (rset2.next()) {
424+ double secondcnt = rset2.getDouble("CNT");
425+
426+ PreparedStatement ps3 = con.prepareStatement("UPDATE NDREF SET idref=?, cnt=? WHERE (idref=?) and (CNT=?)");
427+ ps3.setLong(1, firstwayid);
428+ ps3.setDouble(2, firstcnt + secondcnt + 1.0d);
429+ ps3.setLong(3, secondwayid);
430+ ps3.setDouble(4, secondcnt);
431+ ps3.executeUpdate();
432+ ps3.close();
433+ }
434+ rset2.close();
435+ }
436+ rset1.close();
437+ }
407438
408439 /**
409440 * idref BIGINT member.idref
@@ -442,17 +473,25 @@ public class DbBigrelation
442473 */
443474 public static void delete_NODE(Connection con, OsmNode node) throws SQLException
444475 {
445- PreparedStatement ps = con.prepareStatement("update NODE set action=? where idref=? and osmtype=?");
446- ps.setInt(1, OsmNode.ACTION_DELETE);
447- ps.setLong(2, node.idref);
448- ps.setInt(3, DbBigrelation.OSM_NODE);
449- ps.executeUpdate();
450- ps.close();
476+ if (node.idref < 0) {
477+ PreparedStatement ps1 = con.prepareStatement("delete from NODE where idref=?");
478+ ps1.setLong(1, node.idref);
479+ ps1.executeUpdate();
480+ ps1.close();
481+ }
482+ else {
483+ PreparedStatement ps1 = con.prepareStatement("update NODE set action=? where idref=? and osmtype=?");
484+ ps1.setInt(1, OsmNode.ACTION_DELETE);
485+ ps1.setLong(2, node.idref);
486+ ps1.setInt(3, DbBigrelation.OSM_NODE);
487+ ps1.executeUpdate();
488+ ps1.close();
489+ }
451490
452- ps = con.prepareStatement("delete from NDREF where idref=?");
453- ps.setLong(1, node.idref);
454- ps.executeUpdate();
455- ps.close();
491+ PreparedStatement ps2 = con.prepareStatement("delete from NDREF where idref=?");
492+ ps2.setLong(1, node.idref);
493+ ps2.executeUpdate();
494+ ps2.close();
456495 }
457496
458497 /**
@@ -465,17 +504,25 @@ public class DbBigrelation
465504 */
466505 public static void delete_WAY(Connection con, Way way) throws SQLException
467506 {
468- PreparedStatement ps = con.prepareStatement("update NODE set action=? where idref=? and osmtype=?");
469- ps.setInt(1, OsmNode.ACTION_DELETE);
470- ps.setLong(2, way.idref);
471- ps.setInt(3, DbBigrelation.OSM_WAY);
472- ps.executeUpdate();
473- ps.close();
507+ if (way.idref < 0) {
508+ PreparedStatement ps1 = con.prepareStatement("delete from NODE where idref=?");
509+ ps1.setLong(1, way.idref);
510+ ps1.executeUpdate();
511+ ps1.close();
512+ }
513+ else {
514+ PreparedStatement ps1 = con.prepareStatement("update NODE set action=? where idref=? and osmtype=?");
515+ ps1.setInt(1, OsmNode.ACTION_DELETE);
516+ ps1.setLong(2, way.idref);
517+ ps1.setInt(3, DbBigrelation.OSM_WAY);
518+ ps1.executeUpdate();
519+ ps1.close();
520+ }
474521
475- ps = con.prepareStatement("delete from NDREF where idref=?");
476- ps.setLong(1, way.idref);
477- ps.executeUpdate();
478- ps.close();
522+ PreparedStatement ps2 = con.prepareStatement("delete from NDREF where idref=?");
523+ ps2.setLong(1, way.idref);
524+ ps2.executeUpdate();
525+ ps2.close();
479526 }
480527
481528 /**
@@ -778,6 +825,7 @@ public class DbBigrelation
778825 result.visibleStr = rset.getString("visible");
779826 result.versionStr = rset.getString("version");
780827 result.changeset = rset.getLong("changeset");
828+ result.action = rset.getInt("action");
781829 }
782830 rset.close();
783831 return is;
--- a/src/osm/jp/RelationCutter.java
+++ b/src/osm/jp/RelationCutter.java
@@ -366,6 +366,7 @@ public class RelationCutter {
366366 // MEMBER->WAY
367367 Way way = new Way();
368368 if (!DbBigrelation.getWay(con, way, member.ref)) {
369+ Logger.logger.warning("WAY以外のメンバーがあります。(member:id="+ member.ref +")");
369370 continue;
370371 }
371372
@@ -382,6 +383,8 @@ public class RelationCutter {
382383 OsmNode startNode = way.waynodes.get(0);
383384 OsmNode endNode = way.waynodes.get(way.waynodes.size() -1);
384385 if ((startNode.lat.compareTo(endNode.lat) == 0) && (startNode.lon.compareTo(endNode.lon) == 0)) {
386+ // 既に始点と終点が一致しており、AREAとして閉じています。
387+ Logger.logger.info("AREAとして閉じています。(wayid="+ way.idref +")");
385388 continue;
386389 }
387390 else {
--- a/src/osm/jp/Way.java
+++ b/src/osm/jp/Way.java
@@ -93,6 +93,7 @@ public class Way {
9393
9494 /**
9595 * WAYを接続する
96+ * 別途、リレーションのメンバーから削除する必要があります。
9697 * @param addway
9798 * @throws SQLException
9899 */
@@ -103,5 +104,13 @@ public class Way {
103104 if (lastnode.idref != addway.waynodes.get(0).idref) {
104105 DbBigrelation.delete_NODE(con, lastnode);
105106 }
107+
108+ for (int i =0; i < addway.waynodes.size(); i++) {
109+ this.waynodes.add(addway.waynodes.get(i));
110+ }
111+ addway.action = OsmNode.ACTION_DELETE;
112+
113+ // pending! データベース上のデータも更新する必要がある
114+ DbBigrelation.connect_WAY(con, this.idref, addway.idref);
106115 }
107116 }