From 0569c6983c642512ef64893b8ef9381e21c9ca76 Mon Sep 17 00:00:00 2001 From: Andrey Novikov Date: Tue, 18 Oct 2016 17:16:27 +0300 Subject: [PATCH 1/2] Add completeRelations option to pgsnapshot dataset bounding box filter --- .../core/container/v0_6/DatasetContext.java | 5 ++- .../v0_6/DatasetBoundingBoxFilter.java | 9 ++++-- .../v0_6/DatasetBoundingBoxFilterFactory.java | 6 +++- .../dataset/v0_6/impl/DatasetStoreReader.java | 2 +- .../v0_6/impl/PostgreSqlDatasetContext.java | 2 +- .../v0_6/impl/PostgreSqlDatasetContext.java | 31 ++++++++++++++++++- 6 files changed, 48 insertions(+), 7 deletions(-) diff --git a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java index 9fdea53ff..a2ffa557d 100644 --- a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java +++ b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java @@ -99,8 +99,11 @@ public interface DatasetContext extends Completable { * @param completeWays * If true, all nodes within the ways will be returned even if * they lie outside the box. + * @param completeRelations + * If true, all ways within the relations will be returned even if + * they lie outside the box. * @return An iterator pointing to the start of the result data. */ ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays); + double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations); } diff --git a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java index 783ac00e1..3a84e515c 100644 --- a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java +++ b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java @@ -25,6 +25,7 @@ public class DatasetBoundingBoxFilter implements DatasetSinkSource { private double top; private double bottom; private boolean completeWays; + private boolean completeRelations; private DatasetContext datasetReader; @@ -44,13 +45,17 @@ public class DatasetBoundingBoxFilter implements DatasetSinkSource { * @param completeWays * Include all nodes for ways which have some portion inside the * filtered area. + * @param completeRelations + * Include all ways for relations which have some portion inside the + * filtered area. */ - public DatasetBoundingBoxFilter(double left, double right, double top, double bottom, boolean completeWays) { + public DatasetBoundingBoxFilter(double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { this.left = left; this.right = right; this.top = top; this.bottom = bottom; this.completeWays = completeWays; + this.completeRelations = completeRelations; } @@ -76,7 +81,7 @@ public void process(Dataset dataset) { // Pass all data within the bounding box to the sink. try (ReleasableIterator bboxData = - datasetReader.iterateBoundingBox(left, right, top, bottom, completeWays)) { + datasetReader.iterateBoundingBox(left, right, top, bottom, completeWays, completeRelations)) { sink.initialize(Collections.emptyMap()); diff --git a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilterFactory.java b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilterFactory.java index 994d2d860..94325a716 100644 --- a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilterFactory.java +++ b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilterFactory.java @@ -22,7 +22,9 @@ public class DatasetBoundingBoxFilterFactory extends TaskManagerFactory { private static final double DEFAULT_TOP = 90; private static final double DEFAULT_BOTTOM = -90; private static final String ARG_COMPLETE_WAYS = "completeWays"; + private static final String ARG_COMPLETE_RELATIONS = "completeRelations"; private static final boolean DEFAULT_COMPLETE_WAYS = false; + private static final boolean DEFAULT_COMPLETE_RELATIONS = false; /** @@ -35,6 +37,7 @@ protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) { double top; double bottom; boolean completeWays; + boolean completeRelations; // Get the task arguments. left = getDoubleArgument(taskConfig, ARG_LEFT, DEFAULT_LEFT); @@ -42,10 +45,11 @@ protected TaskManager createTaskManagerImpl(TaskConfiguration taskConfig) { top = getDoubleArgument(taskConfig, ARG_TOP, DEFAULT_TOP); bottom = getDoubleArgument(taskConfig, ARG_BOTTOM, DEFAULT_BOTTOM); completeWays = getBooleanArgument(taskConfig, ARG_COMPLETE_WAYS, DEFAULT_COMPLETE_WAYS); + completeRelations = getBooleanArgument(taskConfig, ARG_COMPLETE_RELATIONS, DEFAULT_COMPLETE_RELATIONS); return new DatasetSinkSourceManager( taskConfig.getId(), - new DatasetBoundingBoxFilter(left, right, top, bottom, completeWays), + new DatasetBoundingBoxFilter(left, right, top, bottom, completeWays, completeRelations), taskConfig.getPipeArgs() ); } diff --git a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java index 42edf7c0a..fb06bb713 100644 --- a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java +++ b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java @@ -472,7 +472,7 @@ private void populateRelationIds(BoundingBoxContext bboxCtx) { */ @Override public ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays) { + double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { BoundingBoxContext bboxCtx; LOG.fine("Beginning bounding box iteration."); diff --git a/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java b/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java index f3354c610..af16e366f 100644 --- a/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java +++ b/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java @@ -226,7 +226,7 @@ public ReleasableIterator iterate() { */ @Override public ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays) { + double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { List bounds; PreparedStatement preparedStatement = null; int prmIndex; diff --git a/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java b/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java index 2c02d3fd0..4fc639c9b 100644 --- a/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java +++ b/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java @@ -221,7 +221,7 @@ public ReleasableIterator iterate() { */ @Override public ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays) { + double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { List bounds; Point[] bboxPoints; Polygon bboxPolygon; @@ -374,6 +374,35 @@ public ReleasableIterator iterateBoundingBox( LOG.finer("Updating query analyzer statistics on the temporary relations table."); jdbcTemplate.update("ANALYZE bbox_relations"); + // If complete relations is set, select all ways contained by the relations into the ways temp table. + if (completeRelations) { + LOG.finer("Selecting all ways for selected relations."); + jdbcTemplate.update( + "CREATE TEMPORARY TABLE bbox_relation_ways ON COMMIT DROP AS" + + " SELECT way_id AS id FROM (" + + " SELECT rm.member_id AS way_id FROM relation_members rm" + + " INNER JOIN bbox_relations br ON rm.relation_id = br.id" + + " WHERE rm.member_type = 'W'" + + " ) wids GROUP BY way_id" + ); + jdbcTemplate.update( + "CREATE TEMPORARY TABLE bbox_missing_ways ON COMMIT DROP AS " + + "SELECT buw.id FROM (SELECT DISTINCT brw.id FROM bbox_relation_ways brw) buw " + + "WHERE NOT EXISTS (" + + " SELECT * FROM bbox_ways WHERE id = buw.id" + + ");" + ); + jdbcTemplate.update("ALTER TABLE ONLY bbox_missing_ways" + + " ADD CONSTRAINT pk_bbox_missing_ways PRIMARY KEY (id)"); + jdbcTemplate.update("ANALYZE bbox_missing_ways"); + rowCount = jdbcTemplate.update("INSERT INTO bbox_ways " + + "SELECT w.* FROM ways w INNER JOIN bbox_missing_ways bw ON w.id = bw.id;"); + LOG.finer(rowCount + " rows affected."); + + LOG.finer("Updating query analyzer statistics on the temporary ways table."); + jdbcTemplate.update("ANALYZE bbox_ways"); + } + // If complete ways is set, select all nodes contained by the ways into the node temp table. if (completeWays) { LOG.finer("Selecting all nodes for selected ways."); From 7ec29b6127f3bbcad87d62922a146e2f688ab89e Mon Sep 17 00:00:00 2001 From: Andrey Novikov Date: Thu, 9 Nov 2017 15:26:15 +0100 Subject: [PATCH 2/2] fix checkstyle errors --- .../core/container/v0_6/DatasetContext.java | 3 +- .../v0_6/DatasetBoundingBoxFilter.java | 6 ++- .../dataset/v0_6/impl/DatasetStoreReader.java | 14 ++++--- .../v0_6/impl/PostgreSqlDatasetContext.java | 41 ++++++++++++------- .../v0_6/impl/PostgreSqlDatasetContext.java | 25 ++++++----- 5 files changed, 56 insertions(+), 33 deletions(-) diff --git a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java index a2ffa557d..47bae925e 100644 --- a/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java +++ b/osmosis-core/src/main/java/org/openstreetmap/osmosis/core/container/v0_6/DatasetContext.java @@ -105,5 +105,6 @@ public interface DatasetContext extends Completable { * @return An iterator pointing to the start of the result data. */ ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations); + double left, double right, double top, double bottom, boolean completeWays, + boolean completeRelations); } diff --git a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java index 3a84e515c..0eb090909 100644 --- a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java +++ b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/DatasetBoundingBoxFilter.java @@ -49,7 +49,8 @@ public class DatasetBoundingBoxFilter implements DatasetSinkSource { * Include all ways for relations which have some portion inside the * filtered area. */ - public DatasetBoundingBoxFilter(double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { + public DatasetBoundingBoxFilter(double left, double right, double top, double bottom, boolean completeWays, + boolean completeRelations) { this.left = left; this.right = right; this.top = top; @@ -81,7 +82,8 @@ public void process(Dataset dataset) { // Pass all data within the bounding box to the sink. try (ReleasableIterator bboxData = - datasetReader.iterateBoundingBox(left, right, top, bottom, completeWays, completeRelations)) { + datasetReader.iterateBoundingBox(left, right, top, bottom, completeWays, + completeRelations)) { sink.initialize(Collections.emptyMap()); diff --git a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java index fb06bb713..5fed145bf 100644 --- a/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java +++ b/osmosis-dataset/src/main/java/org/openstreetmap/osmosis/dataset/v0_6/impl/DatasetStoreReader.java @@ -135,7 +135,8 @@ private ReleasableIterator getRelationIdsOwningWay(long wayId) { */ private ReleasableIterator getRelationIdsOwningRelation(long relationId) { return new RelationalIndexValueIdIterator( - relationStorageContainer.getRelationRelationIndexReader().getRange(relationId, relationId)); + relationStorageContainer.getRelationRelationIndexReader().getRange(relationId, + relationId)); } @@ -343,8 +344,9 @@ private void populateWayIdsUsingTileWayIndex(BoundingBoxContext bboxCtx, boolean // Ignore any referential integrity problems. if (LOG.isLoggable(Level.FINER)) { LOG.finest( - "Ignoring referential integrity problem where way " + wayId - + " refers to non-existent node " + wayNode.getNodeId() + "." + "Ignoring referential integrity problem where way " + + wayId + " refers to non-existent node " + + wayNode.getNodeId() + "." ); } } @@ -449,7 +451,8 @@ private void populateRelationIds(BoundingBoxContext bboxCtx) { moreParents = false; for (Long relationId : bboxCtx.relationIdTracker) { - try (ReleasableIterator relationIdIterator = getRelationIdsOwningRelation(relationId)) { + try (ReleasableIterator relationIdIterator + = getRelationIdsOwningRelation(relationId)) { while (relationIdIterator.hasNext()) { long parentRelationId; @@ -472,7 +475,8 @@ private void populateRelationIds(BoundingBoxContext bboxCtx) { */ @Override public ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { + double left, double right, double top, double bottom, boolean completeWays, + boolean completeRelations) { BoundingBoxContext bboxCtx; LOG.fine("Beginning bounding box iteration."); diff --git a/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java b/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java index af16e366f..c3fd9980d 100644 --- a/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java +++ b/osmosis-pgsimple/src/main/java/org/openstreetmap/osmosis/pgsimple/v0_6/impl/PostgreSqlDatasetContext.java @@ -209,7 +209,8 @@ public ReleasableIterator iterate() { sources = new ArrayList>(); sources.add(new UpcastIterator( - new BoundContainerIterator(new ReleasableAdaptorForIterator(bounds.iterator())))); + new BoundContainerIterator( + new ReleasableAdaptorForIterator(bounds.iterator())))); sources.add(new UpcastIterator( new NodeContainerIterator(nodeDao.iterate()))); sources.add(new UpcastIterator( @@ -226,7 +227,8 @@ public ReleasableIterator iterate() { */ @Override public ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { + double left, double right, double top, double bottom, boolean completeWays, + boolean completeRelations) { List bounds; PreparedStatement preparedStatement = null; int prmIndex; @@ -255,13 +257,16 @@ public ReleasableIterator iterateBoundingBox( // Create a temporary table capable of holding node ids. LOG.finer("Creating node id temp table."); - dbCtx.executeStatement("CREATE TEMPORARY TABLE box_node_list (id bigint PRIMARY KEY) ON COMMIT DROP"); + dbCtx.executeStatement( + "CREATE TEMPORARY TABLE box_node_list (id bigint PRIMARY KEY) ON COMMIT DROP"); // Create a temporary table capable of holding way ids. LOG.finer("Creating way id temp table."); - dbCtx.executeStatement("CREATE TEMPORARY TABLE box_way_list (id bigint PRIMARY KEY) ON COMMIT DROP"); + dbCtx.executeStatement( + "CREATE TEMPORARY TABLE box_way_list (id bigint PRIMARY KEY) ON COMMIT DROP"); // Create a temporary table capable of holding relation ids. LOG.finer("Creating relation id temp table."); - dbCtx.executeStatement("CREATE TEMPORARY TABLE box_relation_list (id bigint PRIMARY KEY) ON COMMIT DROP"); + dbCtx.executeStatement( + "CREATE TEMPORARY TABLE box_relation_list (id bigint PRIMARY KEY) ON COMMIT DROP"); // Build a polygon representing the bounding box. // Sample box for query testing may be: @@ -338,7 +343,8 @@ public ReleasableIterator iterateBoundingBox( // the selected nodes. preparedStatement = dbCtx.prepareStatement( "INSERT INTO box_way_list " - + "SELECT wn.way_id FROM way_nodes wn INNER JOIN box_node_list n ON wn.node_id = n.id" + + "SELECT wn.way_id FROM way_nodes wn INNER JOIN box_node_list n" + + " ON wn.node_id = n.id" + " GROUP BY wn.way_id" ); } @@ -352,8 +358,8 @@ public ReleasableIterator iterateBoundingBox( preparedStatement = dbCtx.prepareStatement( "INSERT INTO box_relation_list (" + "SELECT rm.relation_id AS relation_id FROM relation_members rm" - + " INNER JOIN box_node_list n ON rm.member_id = n.id WHERE rm.member_type = ? " - + "UNION " + + " INNER JOIN box_node_list n ON rm.member_id = n.id WHERE rm.member_type = ?" + + " UNION " + "SELECT rm.relation_id AS relation_id FROM relation_members rm" + " INNER JOIN box_way_list w ON rm.member_id = w.id WHERE rm.member_type = ?" + ")" @@ -373,12 +379,14 @@ public ReleasableIterator iterateBoundingBox( preparedStatement = dbCtx.prepareStatement( "INSERT INTO box_relation_list " + "SELECT rm.relation_id AS relation_id FROM relation_members rm" - + " INNER JOIN box_relation_list r ON rm.member_id = r.id WHERE rm.member_type = ? " + + " INNER JOIN box_relation_list r ON rm.member_id = r.id " + + "WHERE rm.member_type = ? " + "EXCEPT " + "SELECT id AS relation_id FROM box_relation_list" ); prmIndex = 1; - preparedStatement.setString(prmIndex++, memberTypeValueMapper.getMemberType(EntityType.Relation)); + preparedStatement.setString(prmIndex++, + memberTypeValueMapper.getMemberType(EntityType.Relation)); rowCount = preparedStatement.executeUpdate(); preparedStatement.close(); preparedStatement = null; @@ -390,7 +398,8 @@ public ReleasableIterator iterateBoundingBox( LOG.finer("Selecting all node ids for selected ways."); preparedStatement = dbCtx.prepareStatement( "INSERT INTO box_node_list " - + "SELECT wn.node_id AS id FROM way_nodes wn INNER JOIN box_way_list bw ON wn.way_id = bw.id " + + "SELECT wn.node_id AS id FROM way_nodes wn INNER JOIN box_way_list bw" + + " ON wn.way_id = bw.id " + "EXCEPT " + "SELECT id AS node_id FROM box_node_list" ); @@ -411,16 +420,18 @@ public ReleasableIterator iterateBoundingBox( resultSets = new ArrayList>(); resultSets.add( new UpcastIterator( - new BoundContainerIterator(new ReleasableAdaptorForIterator(bounds.iterator())))); + new BoundContainerIterator( + new ReleasableAdaptorForIterator(bounds.iterator())))); resultSets.add( new UpcastIterator( - new NodeContainerIterator(new NodeReader(dbCtx, "box_node_list")))); + new NodeContainerIterator(new NodeReader(dbCtx, "box_node_list")))); resultSets.add( new UpcastIterator( - new WayContainerIterator(new WayReader(dbCtx, "box_way_list")))); + new WayContainerIterator(new WayReader(dbCtx, "box_way_list")))); resultSets.add( new UpcastIterator( - new RelationContainerIterator(new RelationReader(dbCtx, "box_relation_list")))); + new RelationContainerIterator( + new RelationReader(dbCtx, "box_relation_list")))); // Merge all readers into a single result iterator and return. return new MultipleSourceIterator(resultSets); diff --git a/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java b/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java index 4fc639c9b..ece5428b5 100644 --- a/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java +++ b/osmosis-pgsnapshot/src/main/java/org/openstreetmap/osmosis/pgsnapshot/v0_6/impl/PostgreSqlDatasetContext.java @@ -204,7 +204,8 @@ public ReleasableIterator iterate() { sources = new ArrayList>(); sources.add(new UpcastIterator( - new BoundContainerIterator(new ReleasableAdaptorForIterator(bounds.iterator())))); + new BoundContainerIterator( + new ReleasableAdaptorForIterator(bounds.iterator())))); sources.add(new UpcastIterator( new NodeContainerIterator(nodeDao.iterate()))); sources.add(new UpcastIterator( @@ -221,7 +222,8 @@ public ReleasableIterator iterate() { */ @Override public ReleasableIterator iterateBoundingBox( - double left, double right, double top, double bottom, boolean completeWays, boolean completeRelations) { + double left, double right, double top, double bottom, boolean completeWays, + boolean completeRelations) { List bounds; Point[] bboxPoints; Polygon bboxPolygon; @@ -295,8 +297,9 @@ public ReleasableIterator iterateBoundingBox( rowCount = jdbcTemplate.update( "CREATE TEMPORARY TABLE bbox_ways ON COMMIT DROP AS" + " SELECT w.* FROM (" - + "SELECT c.id AS id, First(c.version) AS version, First(c.user_id) AS user_id," - + " First(c.tstamp) AS tstamp, First(c.changeset_id) AS changeset_id, First(c.tags) AS tags," + + "SELECT c.id AS id, First(c.version) AS version, First(c.user_id)" + + " AS user_id, First(c.tstamp) AS tstamp, First(c.changeset_id)" + + " AS changeset_id, First(c.tags) AS tags," + " First(c.nodes) AS nodes, ST_MakeLine(c.geom) AS way_line FROM (" + "SELECT w.*, n.geom AS geom FROM nodes n" + " INNER JOIN way_nodes wn ON n.id = wn.node_id" @@ -349,7 +352,8 @@ public ReleasableIterator iterateBoundingBox( LOG.finer(rowCount + " rows affected."); LOG.finer("Adding a primary key to the temporary relations table."); - jdbcTemplate.update("ALTER TABLE ONLY bbox_relations ADD CONSTRAINT pk_bbox_relations PRIMARY KEY (id)"); + jdbcTemplate.update("ALTER TABLE ONLY bbox_relations ADD CONSTRAINT" + + "pk_bbox_relations PRIMARY KEY (id)"); LOG.finer("Updating query analyzer statistics on the temporary relations table."); jdbcTemplate.update("ANALYZE bbox_relations"); @@ -387,8 +391,8 @@ public ReleasableIterator iterateBoundingBox( ); jdbcTemplate.update( "CREATE TEMPORARY TABLE bbox_missing_ways ON COMMIT DROP AS " - + "SELECT buw.id FROM (SELECT DISTINCT brw.id FROM bbox_relation_ways brw) buw " - + "WHERE NOT EXISTS (" + + "SELECT buw.id FROM (SELECT DISTINCT brw.id FROM bbox_relation_ways brw) buw" + + " WHERE NOT EXISTS (" + " SELECT * FROM bbox_ways WHERE id = buw.id" + ");" ); @@ -418,8 +422,8 @@ public ReleasableIterator iterateBoundingBox( jdbcTemplate.update("ALTER TABLE ONLY bbox_missing_way_nodes" + " ADD CONSTRAINT pk_bbox_missing_way_nodes PRIMARY KEY (id)"); jdbcTemplate.update("ANALYZE bbox_missing_way_nodes"); - rowCount = jdbcTemplate.update("INSERT INTO bbox_nodes " - + "SELECT n.* FROM nodes n INNER JOIN bbox_missing_way_nodes bwn ON n.id = bwn.id;"); + rowCount = jdbcTemplate.update("INSERT INTO bbox_nodes SELECT" + + " n.* FROM nodes n INNER JOIN bbox_missing_way_nodes bwn ON n.id = bwn.id;"); LOG.finer(rowCount + " rows affected."); } @@ -431,7 +435,8 @@ public ReleasableIterator iterateBoundingBox( resultSets = new ArrayList>(); resultSets.add( new UpcastIterator( - new BoundContainerIterator(new ReleasableAdaptorForIterator(bounds.iterator())))); + new BoundContainerIterator( + new ReleasableAdaptorForIterator(bounds.iterator())))); resultSets.add( new UpcastIterator( new NodeContainerIterator(nodeDao.iterate("bbox_"))));