diff --git a/impexp-client-gui/src/main/java/org/citydb/gui/operation/visExporter/preferences/VisExportPreferences.java b/impexp-client-gui/src/main/java/org/citydb/gui/operation/visExporter/preferences/VisExportPreferences.java index 11665b715..d190c3c9a 100644 --- a/impexp-client-gui/src/main/java/org/citydb/gui/operation/visExporter/preferences/VisExportPreferences.java +++ b/impexp-client-gui/src/main/java/org/citydb/gui/operation/visExporter/preferences/VisExportPreferences.java @@ -54,10 +54,18 @@ public VisExportPreferences(ViewController viewController, Config config) { true, true, true, true, config))); renderingNode.addChildEntry(new DefaultPreferencesEntry(new BuildingStylingPanel(config))); - renderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( - "pref.tree.visExport.cityFurniture.styling", + + DefaultPreferencesEntry cityFurnitureRenderingNode = new EmptyPanel( + () -> Language.I18N.getString("pref.tree.visExport.cityFurniture.styling")); + cityFurnitureRenderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( + "pref.tree.visExport.surfaceAndSolid.styling", () -> config.getVisExportConfig().getCityFurnitureStyles(), config))); + cityFurnitureRenderingNode.addChildEntry(new DefaultPreferencesEntry(new PointAndCurveStylingPanel( + () -> config.getVisExportConfig().getCityFurniturePointAndCurve(), + config))); + renderingNode.addChildEntry(cityFurnitureRenderingNode); + renderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( "pref.tree.visExport.cityObjectGroup.styling", () -> config.getVisExportConfig().getReliefStyles(), @@ -85,7 +93,7 @@ public VisExportPreferences(ViewController viewController, Config config) { () -> Language.I18N.getString("pref.tree.visExport.transportation.styling")); transportationComplexRenderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( "pref.tree.visExport.surfaceAndSolid.styling", - () -> config.getVisExportConfig().getGenericCityObjectStyles(), + () -> config.getVisExportConfig().getTransportationStyles(), config))); transportationComplexRenderingNode.addChildEntry(new DefaultPreferencesEntry(new PointAndCurveStylingPanel( () -> config.getVisExportConfig().getTransportationPointAndCurve(), @@ -97,10 +105,18 @@ public VisExportPreferences(ViewController viewController, Config config) { () -> config.getVisExportConfig().getTunnelStyles(), true, true, true, true, config))); - renderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( - "pref.tree.visExport.vegetation.styling", + + DefaultPreferencesEntry vegetationRenderingNode = new EmptyPanel( + () -> Language.I18N.getString("pref.tree.visExport.vegetation.styling")); + vegetationRenderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( + "pref.tree.visExport.surfaceAndSolid.styling", () -> config.getVisExportConfig().getVegetationStyles(), config))); + vegetationRenderingNode.addChildEntry(new DefaultPreferencesEntry(new PointAndCurveStylingPanel( + () -> config.getVisExportConfig().getSolitaryVegetationObjectPointAndCurve(), + config))); + renderingNode.addChildEntry(vegetationRenderingNode); + renderingNode.addChildEntry(new DefaultPreferencesEntry(new SurfaceStylingPanel( "pref.tree.visExport.waterBody.styling", () -> config.getVisExportConfig().getWaterBodyStyles(), diff --git a/impexp-config/src/main/java/org/citydb/config/project/visExporter/VisExportConfig.java b/impexp-config/src/main/java/org/citydb/config/project/visExporter/VisExportConfig.java index 6b62fc721..23b845747 100644 --- a/impexp-config/src/main/java/org/citydb/config/project/visExporter/VisExportConfig.java +++ b/impexp-config/src/main/java/org/citydb/config/project/visExporter/VisExportConfig.java @@ -54,6 +54,7 @@ "landUseBalloon", "vegetationStyles", "vegetationBalloon", + "solitaryVegetationObjectPointAndCurve", "transportationStyles", "transportationBalloon", "transportationPointAndCurve", @@ -61,6 +62,7 @@ "reliefBalloon", "cityFurnitureStyles", "cityFurnitureBalloon", + "cityFurniturePointAndCurve", "genericCityObjectStyles", "genericCityObject3DBalloon", "genericCityObjectPointAndCurve", @@ -107,6 +109,7 @@ public class VisExportConfig { @XmlJavaTypeAdapter(StylesAdapter.class) private Styles vegetationStyles; private Balloon vegetationBalloon; + private PointAndCurve solitaryVegetationObjectPointAndCurve; @XmlJavaTypeAdapter(StylesAdapter.class) private Styles transportationStyles; private Balloon transportationBalloon; @@ -117,6 +120,7 @@ public class VisExportConfig { @XmlJavaTypeAdapter(StylesAdapter.class) private Styles cityFurnitureStyles; private Balloon cityFurnitureBalloon; + private PointAndCurve cityFurniturePointAndCurve; @XmlJavaTypeAdapter(StylesAdapter.class) private Styles genericCityObjectStyles; private Balloon genericCityObject3DBalloon; @@ -166,6 +170,7 @@ public VisExportConfig() { landUseBalloon = new Balloon(); vegetationStyles = new Styles(); vegetationBalloon = new Balloon(); + solitaryVegetationObjectPointAndCurve = new PointAndCurve(); transportationStyles = new Styles(); transportationBalloon = new Balloon(); transportationPointAndCurve = new PointAndCurve(); @@ -173,6 +178,7 @@ public VisExportConfig() { reliefBalloon = new Balloon(); cityFurnitureStyles = new Styles(); cityFurnitureBalloon = new Balloon(); + cityFurniturePointAndCurve = new PointAndCurve(); genericCityObjectStyles = new Styles(); genericCityObject3DBalloon = new Balloon(); genericCityObjectPointAndCurve = new PointAndCurve(); @@ -450,6 +456,14 @@ public void setGenericCityObjectStyles(Styles genericCityObjectStyles) { } } + public void setSolitaryVegetationObjectPointAndCurve(PointAndCurve solitaryVegetationObjectPointAndCurve) { + this.solitaryVegetationObjectPointAndCurve = solitaryVegetationObjectPointAndCurve; + } + + public PointAndCurve getSolitaryVegetationObjectPointAndCurve() { + return solitaryVegetationObjectPointAndCurve; + } + public Styles getGenericCityObjectStyles() { return genericCityObjectStyles; } @@ -488,6 +502,14 @@ public Balloon getCityFurnitureBalloon() { return cityFurnitureBalloon; } + public void setCityFurniturePointAndCurve(PointAndCurve cityFurniturePointAndCurve) { + this.cityFurniturePointAndCurve = cityFurniturePointAndCurve; + } + + public PointAndCurve getCityFurniturePointAndCurve() { + return cityFurniturePointAndCurve; + } + public void setTransportationStyles(Styles transportationStyles) { if (transportationStyles != null) { this.transportationStyles = transportationStyles; @@ -506,8 +528,8 @@ public Balloon getTransportationBalloon() { return transportationBalloon; } - public void setTransportationPointAndCurve(PointAndCurve TransportationPointAndCurve) { - this.transportationPointAndCurve = TransportationPointAndCurve; + public void setTransportationPointAndCurve(PointAndCurve transportationPointAndCurve) { + this.transportationPointAndCurve = transportationPointAndCurve; } public PointAndCurve getTransportationPointAndCurve() { diff --git a/impexp-core/src/main/java/org/citydb/core/ade/visExporter/ADEVisExportQueryHelper.java b/impexp-core/src/main/java/org/citydb/core/ade/visExporter/ADEVisExportQueryHelper.java index eedb062b0..c4723e56c 100644 --- a/impexp-core/src/main/java/org/citydb/core/ade/visExporter/ADEVisExportQueryHelper.java +++ b/impexp-core/src/main/java/org/citydb/core/ade/visExporter/ADEVisExportQueryHelper.java @@ -49,6 +49,8 @@ public interface ADEVisExportQueryHelper { String getSolitaryVegetationObjectQuery(int lodToExportFrom, DisplayForm displayForm, int objectClassId); + String getSolitaryVegetationObjectPointAndCurveQuery(int lodToExportFrom, int objectClassId); + String getPlantCoverQuery(int lodToExportFrom, DisplayForm displayForm, int objectClassId); String getGenericCityObjectQuery(int lodToExportFrom, DisplayForm displayForm, int objectClassId); @@ -57,6 +59,8 @@ public interface ADEVisExportQueryHelper { String getCityFurnitureQuery(int lodToExportFrom, DisplayForm displayForm, int objectClassId); + String getCityFurniturePointAndCurveQuery(int lodToExportFrom, int objectClassId); + String getWaterBodyQuery(int lodToExportFrom, DisplayForm displayForm, int objectClassId); String getLandUseQuery(int lodToExportFrom, DisplayForm displayForm, int objectClassId); diff --git a/impexp-vis-plugin/src/main/java/org/citydb/vis/controller/VisExporter.java b/impexp-vis-plugin/src/main/java/org/citydb/vis/controller/VisExporter.java index dea34e8b9..0b8bcd67a 100644 --- a/impexp-vis-plugin/src/main/java/org/citydb/vis/controller/VisExporter.java +++ b/impexp-vis-plugin/src/main/java/org/citydb/vis/controller/VisExporter.java @@ -897,6 +897,10 @@ private void addStyle(DisplayForm displayForm, int objectClassId, SAXWriter saxW switch (Util.getCityGMLClass(objectClassId)) { case SOLITARY_VEGETATION_OBJECT: + style = config.getVisExportConfig().getVegetationStyles().getOrDefault(type); + styleBasisName = SolitaryVegetationObject.STYLE_BASIS_NAME; + addPointAndCurveStyle(saxWriter, config.getVisExportConfig().getSolitaryVegetationObjectPointAndCurve(), styleBasisName); + break; case PLANT_COVER: style = config.getVisExportConfig().getVegetationStyles().getOrDefault(type); styleBasisName = SolitaryVegetationObject.STYLE_BASIS_NAME; @@ -906,9 +910,9 @@ private void addStyle(DisplayForm displayForm, int objectClassId, SAXWriter saxW case RAILWAY: case ROAD: case SQUARE: - addPointAndCurveStyle(saxWriter, config.getVisExportConfig().getTransportationPointAndCurve(), Transportation.STYLE_BASIS_NAME); style = config.getVisExportConfig().getTransportationStyles().getOrDefault(type); styleBasisName = Transportation.STYLE_BASIS_NAME; + addPointAndCurveStyle(saxWriter, config.getVisExportConfig().getTransportationPointAndCurve(), styleBasisName); break; case RELIEF_FEATURE: style = config.getVisExportConfig().getReliefStyles().getOrDefault(type); @@ -921,11 +925,12 @@ private void addStyle(DisplayForm displayForm, int objectClassId, SAXWriter saxW case CITY_FURNITURE: style = config.getVisExportConfig().getCityFurnitureStyles().getOrDefault(type); styleBasisName = CityFurniture.STYLE_BASIS_NAME; + addPointAndCurveStyle(saxWriter, config.getVisExportConfig().getCityFurniturePointAndCurve(), styleBasisName); break; case GENERIC_CITY_OBJECT: - addPointAndCurveStyle(saxWriter, config.getVisExportConfig().getGenericCityObjectPointAndCurve(), GenericCityObject.STYLE_BASIS_NAME); style = config.getVisExportConfig().getGenericCityObjectStyles().getOrDefault(type); styleBasisName = GenericCityObject.STYLE_BASIS_NAME; + addPointAndCurveStyle(saxWriter, config.getVisExportConfig().getGenericCityObjectPointAndCurve(), styleBasisName); break; case LAND_USE: style = config.getVisExportConfig().getLandUseStyles().getOrDefault(type); diff --git a/impexp-vis-plugin/src/main/java/org/citydb/vis/database/CityFurniture.java b/impexp-vis-plugin/src/main/java/org/citydb/vis/database/CityFurniture.java index efc24a8f0..dc4df4b0a 100644 --- a/impexp-vis-plugin/src/main/java/org/citydb/vis/database/CityFurniture.java +++ b/impexp-vis-plugin/src/main/java/org/citydb/vis/database/CityFurniture.java @@ -54,16 +54,18 @@ public class CityFurniture extends AbstractVisObject { public static final String STYLE_BASIS_NAME = "Furniture"; + private boolean isPointOrCurve; + public CityFurniture(Connection connection, - Query query, - VisExporterManager visExporterManager, - net.opengis.kml._2.ObjectFactory kmlFactory, - AbstractDatabaseAdapter databaseAdapter, - BlobExportAdapter textureExportAdapter, - ElevationServiceHandler elevationServiceHandler, - BalloonTemplateHandler balloonTemplateHandler, - EventDispatcher eventDispatcher, - Config config) { + Query query, + VisExporterManager visExporterManager, + net.opengis.kml._2.ObjectFactory kmlFactory, + AbstractDatabaseAdapter databaseAdapter, + BlobExportAdapter textureExportAdapter, + ElevationServiceHandler elevationServiceHandler, + BalloonTemplateHandler balloonTemplateHandler, + EventDispatcher eventDispatcher, + Config config) { super(connection, query, @@ -96,7 +98,7 @@ public void read(DBSplittingResult work) { try { int lodToExportFrom = config.getVisExportConfig().getLodToExportFrom(); currentLod = lodToExportFrom == 5 ? 4 : lodToExportFrom; - int minLod = lodToExportFrom == 5 ? 1 : lodToExportFrom; + int minLod = lodToExportFrom == 5 ? 0 : lodToExportFrom; while (currentLod >= minLod) { if (!work.getDisplayForm().isAchievableFromLoD(currentLod)) @@ -122,6 +124,28 @@ public void read(DBSplittingResult work) { } catch (SQLException sqle) { } rs = null; + + // check for point or curve + query = queries.getCityFurniturePointAndCurveQuery(currentLod, work.getObjectClassId()); + psQuery = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + for (int i = 1; i <= getParameterCount(query); i++) + psQuery.setLong(i, work.getId()); + + rs = psQuery.executeQuery(); + if (rs.isBeforeFirst()) { + isPointOrCurve = true; + break; // result set not empty + } + + try { + rs.close(); + } catch (SQLException sqle) { + } + try { + psQuery.close(); + } catch (SQLException sqle) { + } + rs = null; } catch (Exception e) { log.error("SQL error while querying the highest available LOD.", e); try { @@ -142,7 +166,8 @@ public void read(DBSplittingResult work) { currentLod--; } - if (rs == null) { // result empty, give up + if ((rs == null) || // result empty + ((!isPointOrCurve) && !work.getDisplayForm().isAchievableFromLoD(currentLod))) { // give up String fromMessage = " from LoD" + lodToExportFrom; if (lodToExportFrom == 5) { if (work.getDisplayForm().getType() == DisplayFormType.COLLADA) @@ -152,86 +177,92 @@ public void read(DBSplittingResult work) { } log.info("Could not display object " + work.getGmlId() + " as " + work.getDisplayForm().getName() + fromMessage + "."); } else { // result not empty - String query = queries.getCityFurnitureQuery(currentLod, work.getDisplayForm(), work.getObjectClassId()); - psQuery = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + visExporterManager.updateFeatureTracker(work); - for (int i = 1; i <= getParameterCount(query); i++) - psQuery.setLong(i, work.getId()); + if (isPointOrCurve) { // point or curve geometry + visExporterManager.print(createPlacemarksForPointOrCurve(rs, work, config.getVisExportConfig().getCityFurniturePointAndCurve()), + work, + getBalloonSettings().isBalloonContentInSeparateFile()); + } else { + String query = queries.getCityFurnitureQuery(currentLod, work.getDisplayForm(), work.getObjectClassId()); + psQuery = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + psQuery.setLong(1, work.getId()); - rs = psQuery.executeQuery(); + for (int i = 1; i <= getParameterCount(query); i++) + psQuery.setLong(i, work.getId()); - visExporterManager.updateFeatureTracker(work); + rs = psQuery.executeQuery(); - switch (work.getDisplayForm().getType()) { - case FOOTPRINT: - visExporterManager.print(createPlacemarksForFootprint(rs, work), - work, - getBalloonSettings().isBalloonContentInSeparateFile()); - break; - - case EXTRUDED: - PreparedStatement psQuery2 = null; - ResultSet rs2 = null; - - try { - query = queries.getExtrusionHeight(); - psQuery2 = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); - for (int i = 1; i <= getParameterCount(query); i++) - psQuery2.setLong(i, work.getId()); - - rs2 = psQuery2.executeQuery(); - rs2.next(); - - double measuredHeight = rs2.getDouble("envelope_measured_height"); - visExporterManager.print(createPlacemarksForExtruded(rs, work, measuredHeight, false), - work, getBalloonSettings().isBalloonContentInSeparateFile()); + switch (work.getDisplayForm().getType()) { + case FOOTPRINT: + visExporterManager.print(createPlacemarksForFootprint(rs, work), + work, + getBalloonSettings().isBalloonContentInSeparateFile()); break; - } finally { - try { - if (rs2 != null) rs2.close(); - } catch (SQLException e) { - } + + case EXTRUDED: + PreparedStatement psQuery2 = null; + ResultSet rs2 = null; + try { - if (psQuery2 != null) psQuery2.close(); - } catch (SQLException e) { + query = queries.getExtrusionHeight(); + psQuery2 = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + for (int i = 1; i <= getParameterCount(query); i++) + psQuery2.setLong(i, work.getId()); + + rs2 = psQuery2.executeQuery(); + rs2.next(); + + double measuredHeight = rs2.getDouble("envelope_measured_height"); + visExporterManager.print(createPlacemarksForExtruded(rs, work, measuredHeight, false), + work, getBalloonSettings().isBalloonContentInSeparateFile()); + break; + } finally { + try { + if (rs2 != null) rs2.close(); + } catch (SQLException e) { + } + try { + if (psQuery2 != null) psQuery2.close(); + } catch (SQLException e) { + } } - } - - case GEOMETRY: - setGmlId(work.getGmlId()); - setId(work.getId()); - visExporterManager.print(createPlacemarksForGeometry(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); - if (getStyle(work.getDisplayForm().getType()).isHighlightingEnabled()) - visExporterManager.print(createPlacemarksForHighlighting(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); - break; - - case COLLADA: - ColladaOptions colladaOptions = config.getVisExportConfig().getColladaOptions(); - - String currentgmlId = getGmlId(); - setGmlId(work.getGmlId()); - setId(work.getId()); - fillGenericObjectForCollada(rs, colladaOptions.isGenerateTextureAtlases()); - - if (currentgmlId != null && !currentgmlId.equals(work.getGmlId()) && getGeometryAmount() > GEOMETRY_AMOUNT_WARNING) - log.info("Object " + work.getGmlId() + " has more than " + GEOMETRY_AMOUNT_WARNING + " geometries. This may take a while to process..."); - - List anchorCandidates = getOrigins(); - double zOffset = getZOffsetFromConfigOrDB(work.getId()); - if (zOffset == Double.MAX_VALUE) { - zOffset = getZOffsetFromGEService(work.getId(), anchorCandidates); - } - setZOffset(zOffset); - - setIgnoreSurfaceOrientation(colladaOptions.isIgnoreSurfaceOrientation()); - try { + + case GEOMETRY: + setGmlId(work.getGmlId()); + setId(work.getId()); + visExporterManager.print(createPlacemarksForGeometry(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); if (getStyle(work.getDisplayForm().getType()).isHighlightingEnabled()) visExporterManager.print(createPlacemarksForHighlighting(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); - } catch (Exception ioe) { - log.logStackTrace(ioe); - } + break; - break; + case COLLADA: + ColladaOptions colladaOptions = config.getVisExportConfig().getColladaOptions(); + String currentgmlId = getGmlId(); + setGmlId(work.getGmlId()); + setId(work.getId()); + fillGenericObjectForCollada(rs, colladaOptions.isGenerateTextureAtlases()); + + if (currentgmlId != null && !currentgmlId.equals(work.getGmlId()) && getGeometryAmount() > GEOMETRY_AMOUNT_WARNING) + log.info("Object " + work.getGmlId() + " has more than " + GEOMETRY_AMOUNT_WARNING + " geometries. This may take a while to process..."); + + List anchorCandidates = getOrigins(); + double zOffset = getZOffsetFromConfigOrDB(work.getId()); + if (zOffset == Double.MAX_VALUE) { + zOffset = getZOffsetFromGEService(work.getId(), anchorCandidates); + } + setZOffset(zOffset); + + setIgnoreSurfaceOrientation(colladaOptions.isIgnoreSurfaceOrientation()); + try { + if (getStyle(work.getDisplayForm().getType()).isHighlightingEnabled()) + visExporterManager.print(createPlacemarksForHighlighting(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); + } catch (Exception ioe) { + log.logStackTrace(ioe); + } + + break; + } } } } catch (SQLException sqlEx) { @@ -262,5 +293,4 @@ public PlacemarkType createPlacemarkForColladaModel() throws SQLException { return super.createPlacemarkForColladaModel(); } - } diff --git a/impexp-vis-plugin/src/main/java/org/citydb/vis/database/Queries.java b/impexp-vis-plugin/src/main/java/org/citydb/vis/database/Queries.java index bc0bdda09..122a4fdc9 100644 --- a/impexp-vis-plugin/src/main/java/org/citydb/vis/database/Queries.java +++ b/impexp-vis-plugin/src/main/java/org/citydb/vis/database/Queries.java @@ -1556,6 +1556,26 @@ public String getSolitaryVegetationObjectQuery(int lodToExportFrom, DisplayForm return query; } + @Override + public String getSolitaryVegetationObjectPointAndCurveQuery(int lodToExportFrom, int objectClassId) { + String query; + + query = new StringBuilder().append("SELECT svo.lod").append(lodToExportFrom).append("_other_geom, ") + .append(implicitGeometryNullColumns) + .append("FROM ").append(schema).append(".SOLITARY_VEGETAT_OBJECT svo ") + .append("WHERE svo.id = ? ") + .append("AND svo.lod").append(lodToExportFrom).append("_other_geom IS NOT NULL ") + .append("UNION ALL ") + .append("SELECT ig.relative_other_geom, svo.lod").append(lodToExportFrom).append("_implicit_rep_id, svo.lod").append(lodToExportFrom).append("_implicit_ref_point, svo.lod").append(lodToExportFrom).append("_implicit_transformation ") + .append("FROM ").append(schema).append(".IMPLICIT_GEOMETRY ig ") + .append("LEFT JOIN ").append(schema).append(".SOLITARY_VEGETAT_OBJECT svo ON ig.id = svo.lod").append(lodToExportFrom).append("_implicit_rep_id ") + .append("WHERE svo.id = ? ") + .append("AND ig.relative_other_geom IS NOT NULL").toString(); + + query = unionADEQueries(QUERY_POINT_AND_CURVE_GEOMETRY, query, lodToExportFrom, objectClassId); + return query; + } + // ---------------------------------------------------------------------- // PLANT COVER QUERIES // ---------------------------------------------------------------------- @@ -1705,6 +1725,27 @@ public String getCityFurnitureQuery(int lodToExportFrom, DisplayForm displayForm return query; } + @Override + public String getCityFurniturePointAndCurveQuery(int lodToExportFrom, int objectClassId) { + String query; + + query = new StringBuilder().append("SELECT cf.lod").append(lodToExportFrom).append("_other_geom, ") + .append(implicitGeometryNullColumns) + .append("FROM ").append(schema).append(".CITY_FURNITURE cf ") + .append("WHERE cf.id = ? ") + .append("AND cf.lod").append(lodToExportFrom).append("_other_geom IS NOT NULL ") + .append("UNION ALL ") + .append("SELECT ig.relative_other_geom, cf.lod").append(lodToExportFrom).append("_implicit_rep_id, cf.lod").append(lodToExportFrom).append("_implicit_ref_point, cf.lod").append(lodToExportFrom).append("_implicit_transformation ") + .append("FROM ").append(schema).append(".IMPLICIT_GEOMETRY ig ") + .append("LEFT JOIN ").append(schema).append(".CITY_FURNITURE cf ON ig.id = cf.lod").append(lodToExportFrom).append("_implicit_rep_id ") + .append("WHERE cf.id = ? ") + .append("AND ig.relative_other_geom IS NOT NULL").toString(); + + query = unionADEQueries(QUERY_POINT_AND_CURVE_GEOMETRY, query, lodToExportFrom, objectClassId); + return query; + } + + // ---------------------------------------------------------------------- // WATER BODY QUERIES // ---------------------------------------------------------------------- diff --git a/impexp-vis-plugin/src/main/java/org/citydb/vis/database/SolitaryVegetationObject.java b/impexp-vis-plugin/src/main/java/org/citydb/vis/database/SolitaryVegetationObject.java index 81efad867..053889dd7 100644 --- a/impexp-vis-plugin/src/main/java/org/citydb/vis/database/SolitaryVegetationObject.java +++ b/impexp-vis-plugin/src/main/java/org/citydb/vis/database/SolitaryVegetationObject.java @@ -54,16 +54,18 @@ public class SolitaryVegetationObject extends AbstractVisObject { public static final String STYLE_BASIS_NAME = "Vegetation"; + private boolean isPointOrCurve; + public SolitaryVegetationObject(Connection connection, - Query query, - VisExporterManager visExporterManager, - net.opengis.kml._2.ObjectFactory kmlFactory, - AbstractDatabaseAdapter databaseAdapter, - BlobExportAdapter textureExportAdapter, - ElevationServiceHandler elevationServiceHandler, - BalloonTemplateHandler balloonTemplateHandler, - EventDispatcher eventDispatcher, - Config config) { + Query query, + VisExporterManager visExporterManager, + net.opengis.kml._2.ObjectFactory kmlFactory, + AbstractDatabaseAdapter databaseAdapter, + BlobExportAdapter textureExportAdapter, + ElevationServiceHandler elevationServiceHandler, + BalloonTemplateHandler balloonTemplateHandler, + EventDispatcher eventDispatcher, + Config config) { super(connection, query, @@ -96,7 +98,7 @@ public void read(DBSplittingResult work) { try { int lodToExportFrom = config.getVisExportConfig().getLodToExportFrom(); currentLod = lodToExportFrom == 5 ? 4 : lodToExportFrom; - int minLod = lodToExportFrom == 5 ? 1 : lodToExportFrom; + int minLod = lodToExportFrom == 5 ? 0 : lodToExportFrom; while (currentLod >= minLod) { if (!work.getDisplayForm().isAchievableFromLoD(currentLod)) @@ -122,6 +124,28 @@ public void read(DBSplittingResult work) { } catch (SQLException sqle) { } rs = null; + + // check for point or curve + query = queries.getSolitaryVegetationObjectPointAndCurveQuery(currentLod, work.getObjectClassId()); + psQuery = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + for (int i = 1; i <= getParameterCount(query); i++) + psQuery.setLong(i, work.getId()); + + rs = psQuery.executeQuery(); + if (rs.isBeforeFirst()) { + isPointOrCurve = true; + break; // result set not empty + } + + try { + rs.close(); + } catch (SQLException sqle) { + } + try { + psQuery.close(); + } catch (SQLException sqle) { + } + rs = null; } catch (Exception e) { log.error("SQL error while querying the highest available LOD.", e); try { @@ -142,7 +166,8 @@ public void read(DBSplittingResult work) { currentLod--; } - if (rs == null) { // result empty, give up + if ((rs == null) || // result empty + ((!isPointOrCurve) && !work.getDisplayForm().isAchievableFromLoD(currentLod))) { // give up String fromMessage = " from LoD" + lodToExportFrom; if (lodToExportFrom == 5) { if (work.getDisplayForm().getType() == DisplayFormType.COLLADA) @@ -152,86 +177,92 @@ public void read(DBSplittingResult work) { } log.info("Could not display object " + work.getGmlId() + " as " + work.getDisplayForm().getName() + fromMessage + "."); } else { // result not empty - String query = queries.getSolitaryVegetationObjectQuery(currentLod, work.getDisplayForm(), work.getObjectClassId()); - psQuery = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + visExporterManager.updateFeatureTracker(work); - for (int i = 1; i <= getParameterCount(query); i++) - psQuery.setLong(i, work.getId()); + if (isPointOrCurve) { // point or curve geometry + visExporterManager.print(createPlacemarksForPointOrCurve(rs, work, config.getVisExportConfig().getSolitaryVegetationObjectPointAndCurve()), + work, + getBalloonSettings().isBalloonContentInSeparateFile()); + } else { + String query = queries.getSolitaryVegetationObjectQuery(currentLod, work.getDisplayForm(), work.getObjectClassId()); + psQuery = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + psQuery.setLong(1, work.getId()); - rs = psQuery.executeQuery(); + for (int i = 1; i <= getParameterCount(query); i++) + psQuery.setLong(i, work.getId()); - visExporterManager.updateFeatureTracker(work); + rs = psQuery.executeQuery(); - switch (work.getDisplayForm().getType()) { - case FOOTPRINT: - visExporterManager.print(createPlacemarksForFootprint(rs, work), - work, - getBalloonSettings().isBalloonContentInSeparateFile()); - break; - - case EXTRUDED: - PreparedStatement psQuery2 = null; - ResultSet rs2 = null; - - try { - query = queries.getExtrusionHeight(); - psQuery2 = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); - for (int i = 1; i <= getParameterCount(query); i++) - psQuery2.setLong(i, work.getId()); - - rs2 = psQuery2.executeQuery(); - rs2.next(); - - double measuredHeight = rs2.getDouble("envelope_measured_height"); - visExporterManager.print(createPlacemarksForExtruded(rs, work, measuredHeight, false), - work, getBalloonSettings().isBalloonContentInSeparateFile()); + switch (work.getDisplayForm().getType()) { + case FOOTPRINT: + visExporterManager.print(createPlacemarksForFootprint(rs, work), + work, + getBalloonSettings().isBalloonContentInSeparateFile()); break; - } finally { - try { - if (rs2 != null) rs2.close(); - } catch (SQLException e) { - } + + case EXTRUDED: + PreparedStatement psQuery2 = null; + ResultSet rs2 = null; + try { - if (psQuery2 != null) psQuery2.close(); - } catch (SQLException e) { + query = queries.getExtrusionHeight(); + psQuery2 = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); + for (int i = 1; i <= getParameterCount(query); i++) + psQuery2.setLong(i, work.getId()); + + rs2 = psQuery2.executeQuery(); + rs2.next(); + + double measuredHeight = rs2.getDouble("envelope_measured_height"); + visExporterManager.print(createPlacemarksForExtruded(rs, work, measuredHeight, false), + work, getBalloonSettings().isBalloonContentInSeparateFile()); + break; + } finally { + try { + if (rs2 != null) rs2.close(); + } catch (SQLException e) { + } + try { + if (psQuery2 != null) psQuery2.close(); + } catch (SQLException e) { + } } - } - - case GEOMETRY: - setGmlId(work.getGmlId()); - setId(work.getId()); - visExporterManager.print(createPlacemarksForGeometry(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); - if (getStyle(work.getDisplayForm().getType()).isHighlightingEnabled()) - visExporterManager.print(createPlacemarksForHighlighting(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); - break; - - case COLLADA: - ColladaOptions colladaOptions = config.getVisExportConfig().getColladaOptions(); - - String currentgmlId = getGmlId(); - setGmlId(work.getGmlId()); - setId(work.getId()); - fillGenericObjectForCollada(rs, colladaOptions.isGenerateTextureAtlases()); - - if (currentgmlId != null && !currentgmlId.equals(work.getGmlId()) && getGeometryAmount() > GEOMETRY_AMOUNT_WARNING) - log.info("Object " + work.getGmlId() + " has more than " + GEOMETRY_AMOUNT_WARNING + " geometries. This may take a while to process..."); - - List anchorCandidates = getOrigins(); - double zOffset = getZOffsetFromConfigOrDB(work.getId()); - if (zOffset == Double.MAX_VALUE) { - zOffset = getZOffsetFromGEService(work.getId(), anchorCandidates); - } - setZOffset(zOffset); - - setIgnoreSurfaceOrientation(colladaOptions.isIgnoreSurfaceOrientation()); - try { + + case GEOMETRY: + setGmlId(work.getGmlId()); + setId(work.getId()); + visExporterManager.print(createPlacemarksForGeometry(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); if (getStyle(work.getDisplayForm().getType()).isHighlightingEnabled()) visExporterManager.print(createPlacemarksForHighlighting(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); - } catch (Exception ioe) { - log.logStackTrace(ioe); - } + break; - break; + case COLLADA: + ColladaOptions colladaOptions = config.getVisExportConfig().getColladaOptions(); + String currentgmlId = getGmlId(); + setGmlId(work.getGmlId()); + setId(work.getId()); + fillGenericObjectForCollada(rs, colladaOptions.isGenerateTextureAtlases()); + + if (currentgmlId != null && !currentgmlId.equals(work.getGmlId()) && getGeometryAmount() > GEOMETRY_AMOUNT_WARNING) + log.info("Object " + work.getGmlId() + " has more than " + GEOMETRY_AMOUNT_WARNING + " geometries. This may take a while to process..."); + + List anchorCandidates = getOrigins(); + double zOffset = getZOffsetFromConfigOrDB(work.getId()); + if (zOffset == Double.MAX_VALUE) { + zOffset = getZOffsetFromGEService(work.getId(), anchorCandidates); + } + setZOffset(zOffset); + + setIgnoreSurfaceOrientation(colladaOptions.isIgnoreSurfaceOrientation()); + try { + if (getStyle(work.getDisplayForm().getType()).isHighlightingEnabled()) + visExporterManager.print(createPlacemarksForHighlighting(rs, work), work, getBalloonSettings().isBalloonContentInSeparateFile()); + } catch (Exception ioe) { + log.logStackTrace(ioe); + } + + break; + } } } } catch (SQLException sqlEx) { @@ -262,5 +293,4 @@ public PlacemarkType createPlacemarkForColladaModel() throws SQLException { return super.createPlacemarkForColladaModel(); } - }