Skip to content

Commit

Permalink
Merge remote-tracking branch 'deegree/3.5-main' into fix/gmlToolRefer…
Browse files Browse the repository at this point in the history
…enceDataXPath-9590-181
  • Loading branch information
lgoltz committed Apr 8, 2024
2 parents 7d60e03 + 5596605 commit 138437c
Show file tree
Hide file tree
Showing 135 changed files with 699 additions and 190 deletions.
2 changes: 1 addition & 1 deletion deegree-client/deegree-jsf-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-client</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-client/deegree-wps-webclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-client</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion deegree-client/deegree-wpsprinter-webclient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-client</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion deegree-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<modules>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-connectionprovider-datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-3d/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
Expand All @@ -44,7 +43,7 @@ public class GeoJsonWriter extends JsonWriter implements GeoJsonFeatureWriter, G

private static final Logger LOG = LoggerFactory.getLogger(GeoJsonWriter.class);

private final GeoJsonGeometryWriter geoJsonGeometryWriter;
private GeoJsonGeometryWriter geoJsonGeometryWriter;

private final ICRS crs;

Expand All @@ -58,10 +57,25 @@ public class GeoJsonWriter extends JsonWriter implements GeoJsonFeatureWriter, G
* @throws UnknownCRSException if "crs:84" is not known as CRS (should never happen)
*/
public GeoJsonWriter(Writer writer, ICRS crs) throws UnknownCRSException {
this(writer, crs, false);
}

/**
* Instantiates a new {@link GeoJsonWriter}.
* @param writer the writer to write the GeoJSON into, never <code>null</code>
* @param crs the target crs of the geometries, may be <code>null</code>, then
* "EPSG:4326" will be used
* @param skipGeometries <code>true</code> if geometries should not be exported,
* <code>false</code> otherwise
* @throws UnknownCRSException if "crs:84" is not known as CRS (should never happen)
*/
public GeoJsonWriter(Writer writer, ICRS crs, boolean skipGeometries) throws UnknownCRSException {
super(writer);
setIndent(" ");
setHtmlSafe(true);
this.geoJsonGeometryWriter = new GeoJsonGeometryWriter(this, crs);
if (!skipGeometries) {
this.geoJsonGeometryWriter = new GeoJsonGeometryWriter(this, crs);
}
this.crs = crs;
}

Expand Down Expand Up @@ -119,6 +133,8 @@ public void writeSingleFeature(Feature feature) throws IOException, UnknownCRSEx
}

private void writeGeometry(Feature feature) throws IOException, UnknownCRSException, TransformationException {
if (geoJsonGeometryWriter == null)
return;
List<Property> geometryProperties = feature.getGeometryProperties();
if (geometryProperties.isEmpty()) {
name("geometry").nullValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasNoJsonPath;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.Assert.assertThat;

/**
Expand Down Expand Up @@ -56,6 +57,39 @@ public void testWrite() throws Exception {

}

@Test
public void testWrite_skipGeometries() throws Exception {
StringWriter featureAsJson = new StringWriter();
GeoJsonWriter geoJsonFeatureWriter = new GeoJsonWriter(featureAsJson, null, true);
Feature cadastralZoning = parseFeature("CadastralZoning.gml");

geoJsonFeatureWriter.startFeatureCollection();
geoJsonFeatureWriter.write(cadastralZoning);
geoJsonFeatureWriter.endFeatureCollection();

String featureCollection = featureAsJson.toString();

assertThat(featureCollection, JsonPathMatchers.isJson());
assertThat(featureCollection, hasJsonPath("$.type", is("FeatureCollection")));
assertThat(featureCollection, hasJsonPath("$.features.length()", is(1)));
assertThat(featureCollection, hasJsonPath("$.features[0].type", is("Feature")));
assertThat(featureCollection, hasNoJsonPath("$.features[0].srsName"));
assertThat(featureCollection, hasJsonPath("$.features[0].id", is("CP_CADASTRALZONING_Bundesland_02")));
assertThat(featureCollection, not(hasJsonPath("$.features[0].geometry")));
assertThat(featureCollection, hasJsonPath("$.features[0].properties.label", is("02")));
assertThat(featureCollection, hasJsonPath("$.features[0].properties.originalMapScaleDenominator", is(10)));
assertThat(featureCollection,
hasJsonPath("$.features[0].properties.beginLifespanVersion", is("2009-12-15T08:04:54Z")));
assertThat(featureCollection, hasJsonPath("$.features[0].properties.estimatedAccuracy.uom", is("m")));
assertThat(featureCollection, hasJsonPath("$.features[0].properties.inspireId.Identifier.localId",
is("urn:adv:oid:DEHHALKA10000005")));
assertThat(featureCollection, hasJsonPath(
"$.features[0].properties.name.GeographicalName.spelling.SpellingOfName.text", is("Hamburg")));
assertThat(featureCollection,
hasJsonPath("$.features[0].properties.levelName.LocalisedCharacterString.value", is("Bundesland")));

}

@Test
public void testWrite_SingleFeature() throws Exception {
StringWriter featureAsJson = new StringWriter();
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-coverage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-cs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion deegree-core/deegree-core-featureinfo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-core</artifactId>
<version>3.5.6-SNAPSHOT</version>
<version>3.5.7-SNAPSHOT</version>
</parent>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
Expand All @@ -52,6 +53,8 @@ public interface FeatureInfoContext {

XMLStreamWriter getXmlWriter() throws IOException, XMLStreamException;

Writer getWriter() throws IOException;

void sendRedirect(String location) throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ Occam Labs UG (haftungsbeschränkt)
----------------------------------------------------------------------------*/
package org.deegree.featureinfo;

import static org.slf4j.LoggerFactory.getLogger;

import java.io.IOException;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import javax.xml.stream.XMLStreamException;

import org.deegree.featureinfo.serializing.FeatureInfoGmlWriter;
import org.deegree.featureinfo.serializing.FeatureInfoSerializer;
import org.deegree.featureinfo.serializing.GeoJsonFeatureInfoSerializer;
import org.deegree.featureinfo.serializing.PlainTextFeatureInfoSerializer;
import org.deegree.featureinfo.serializing.TemplateFeatureInfoSerializer;
import org.deegree.featureinfo.serializing.XsltFeatureInfoSerializer;
import org.deegree.gml.GMLVersion;
import org.deegree.workspace.Workspace;
import org.slf4j.Logger;

import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.net.URL;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

import static org.slf4j.LoggerFactory.getLogger;

/**
* Responsible for managing feature info output formats and their serializers.
*
Expand Down Expand Up @@ -112,6 +112,14 @@ public void addOrReplaceXsltFormat(String format, URL xsltUrl, GMLVersion versio
featureInfoSerializers.put(format, xslt);
}

public void addOrReplaceGeoJsonFormat(String format, boolean allowOtherCrsThanWGS84,
boolean allowExportOfGeometries) {
LOG.debug("Adding GeoJson feature info format");
GeoJsonFeatureInfoSerializer geoJsonSerializer = new GeoJsonFeatureInfoSerializer(allowOtherCrsThanWGS84,
allowExportOfGeometries);
featureInfoSerializers.put(format, geoJsonSerializer);
}

public Set<String> getSupportedFormats() {
return featureInfoSerializers.keySet();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,18 @@ public class FeatureInfoParams {

private ICRS crs;

private final ICRS infoCrs;

public FeatureInfoParams(Map<String, String> nsBindings, FeatureCollection col, String format,
boolean withGeometries, String schemaLocation, FeatureType type, ICRS crs) {
boolean withGeometries, String schemaLocation, FeatureType type, ICRS crs, ICRS infoCrs) {
this.nsBindings = nsBindings;
this.featureCollection = col;
this.format = format;
this.withGeometries = withGeometries;
this.schemaLocation = schemaLocation;
this.featureType = type;
this.crs = crs;
this.infoCrs = infoCrs;
}

/**
Expand Down Expand Up @@ -128,4 +131,11 @@ public ICRS getCrs() {
return crs;
}

/**
* @return the CRS of the values to return
*/
public ICRS getInfoCrs() {
return infoCrs;
}

}
Loading

0 comments on commit 138437c

Please sign in to comment.