Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEOS-11486] Mapml Adding customdims to mapMl document #371

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
307 changes: 4 additions & 303 deletions doc/en/user/source/extensions/mapml/index.rst

Large diffs are not rendered by default.

319 changes: 319 additions & 0 deletions doc/en/user/source/extensions/mapml/installation.rst

Large diffs are not rendered by default.

442 changes: 442 additions & 0 deletions doc/en/user/source/extensions/mapml/template.rst

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions doc/en/user/source/production/java.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,16 @@ GeoServer is compatible with Java 17, but requires extra care for running in som

Deployment on Tomcat 9.0.55 has been tested with success.

The "bin" packaging can work too, but requires turning off the Marlin rasterizer integration.
This can be done by modifying the scripts, or by simply removing the Marlin jars::
GeoServer code depends on a variety of libraries trying to access the JDK internals.
It does not seem to matter when running as a web application. However, in case of need,
here is the full list of opens used by the build process::

rm webapps/geoserver/WEB-INF/lib/marlin-0.9.3.jar


GeoServer code depends on a variety of libraries trying to access the JDK internals. As reported above,
it does not seem to matter when running as a web application. However, in case of need, here is
the full list of opens used by the build process::

--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens=java.desktop/sun.java2d.pipe=ALL-UNNAMED

Running on Java 11
------------------

GeoServer 2.15 will run under Java 11 with no additional configuration on **Tomcat 9** or newer and **Jetty 9.4.12** or newer.
GeoServer 2.15 and above will run under Java 11 with no additional configuration on **Tomcat 9** or newer and **Jetty 9.4.12** or newer.

Running GeoServer under Java 11 on other Application Servers may require some additional configuration. Some Application Servers do not support Java 11 yet.

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public void encode(Mapml mapml, OutputStream output) {
public Mapml decode(Reader reader) {
try {
Unmarshaller unmarshaller = context.createUnmarshaller();
unmarshaller.setEventHandler(
new javax.xml.bind.helpers.DefaultValidationEventHandler());
return (Mapml) unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new ServiceException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
import static org.geoserver.mapml.MapMLConstants.MAPML_FEATURE_FO;
import static org.geoserver.mapml.MapMLConstants.MAPML_SKIP_ATTRIBUTES_FO;
import static org.geoserver.mapml.MapMLConstants.MAPML_SKIP_STYLES_FO;
import static org.geoserver.mapml.template.MapMLMapTemplate.MAPML_FEATURE_FTL;
import static org.geoserver.mapml.template.MapMLMapTemplate.MAPML_FEATURE_HEAD_FTL;

import freemarker.template.TemplateNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -19,12 +23,14 @@
import java.util.StringJoiner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.bind.JAXBException;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.MetadataMap;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.gwc.layer.GeoServerTileLayer;
import org.geoserver.mapml.tcrs.TiledCRSConstants;
import org.geoserver.mapml.tcrs.TiledCRSParams;
import org.geoserver.mapml.template.MapMLMapTemplate;
import org.geoserver.mapml.xml.BodyContent;
import org.geoserver.mapml.xml.Feature;
import org.geoserver.mapml.xml.HeadContent;
Expand All @@ -37,6 +43,7 @@
import org.geoserver.ows.URLMangler;
import org.geoserver.ows.util.ResponseUtils;
import org.geoserver.platform.ServiceException;
import org.geoserver.wms.featureinfo.FeatureTemplate;
import org.geotools.api.feature.simple.SimpleFeature;
import org.geotools.api.referencing.FactoryException;
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
Expand All @@ -56,6 +63,16 @@ public class MapMLFeatureUtil {
public static final String STYLE_CLASS_PREFIX = ".";
public static final String STYLE_CLASS_DELIMITER = " ";
public static final String BBOX_DISPLAY_NONE = ".bbox {display:none}";
private static final MapMLMapTemplate mapMLMapTemplate = new MapMLMapTemplate();
private static final MapMLEncoder encoder;

static {
try {
encoder = new MapMLEncoder();
} catch (JAXBException e) {
throw new ServiceException(e);
}
}

/**
* Convert a feature collection to a MapML document
Expand Down Expand Up @@ -91,6 +108,24 @@ public static Mapml featureCollectionToMapML(
throw new ServiceException("MapML OutputFormat does not support Complex Features.");
}
SimpleFeatureCollection fc = (SimpleFeatureCollection) featureCollection;
boolean hasTemplate = false;
boolean hasHeadTemplate = false;
try {
if (!mapMLMapTemplate.isTemplateEmpty(
fc.getSchema(), MAPML_FEATURE_HEAD_FTL, FeatureTemplate.class, "0\n")) {
hasHeadTemplate = true;
}
} catch (TemplateNotFoundException e) {
LOGGER.log(Level.FINEST, MAPML_FEATURE_HEAD_FTL + " Template not found", e);
}
try {
if (!mapMLMapTemplate.isTemplateEmpty(
fc.getSchema(), MAPML_FEATURE_FTL, FeatureTemplate.class, "0\n")) {
hasTemplate = true;
}
} catch (TemplateNotFoundException e) {
LOGGER.log(Level.FINEST, MAPML_FEATURE_FTL + " Template not found", e);
}

ResourceInfo resourceInfo = layerInfo.getResource();
MetadataMap layerMeta = resourceInfo.getMetadata();
Expand Down Expand Up @@ -132,7 +167,12 @@ public static Mapml featureCollectionToMapML(
if (!skipHeadStyles) {
String style = getCSSStylesFull(styles);
head.setStyle(style);
if (hasHeadTemplate) {
getInterpolatedStylesFromTemplate(fc)
.ifPresent(interpolated -> appendTemplateCSSStyle(head, interpolated));
}
}

String fCaptionTemplate = layerMeta.get("mapml.featureCaption", String.class);
mapml.setHead(head);

Expand All @@ -151,25 +191,82 @@ public static Mapml featureCollectionToMapML(
try (SimpleFeatureIterator iterator = fc.features()) {
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
Optional<Mapml> interpolatedOptional = Optional.empty();
if (hasTemplate) {
interpolatedOptional = getInterpolatedFromTemplate(fc, feature);
}
// convert feature to xml
if (styles != null) {
List<MapMLStyle> applicableStyles = getApplicableStyles(feature, styles);
Optional<Feature> f =
featureBuilder.buildFeature(
feature, fCaptionTemplate, applicableStyles);
feature,
fCaptionTemplate,
applicableStyles,
interpolatedOptional);
// feature will be skipped if geometry incompatible with style symbolizer
f.ifPresent(features::add);
} else {
// WFS GETFEATURE request with no styles
Optional<Feature> f =
featureBuilder.buildFeature(feature, fCaptionTemplate, null);
featureBuilder.buildFeature(
feature, fCaptionTemplate, null, interpolatedOptional);
f.ifPresent(features::add);
}
}
}
return mapml;
}

private static Optional<Mapml> getInterpolatedFromTemplate(
SimpleFeatureCollection fc, SimpleFeature feature) {
String templateOutput = "Error parsing template output";
try {
templateOutput = mapMLMapTemplate.features(fc.getSchema(), feature);
Mapml out = encoder.decode(new StringReader(templateOutput));
return Optional.of(out);
} catch (Exception e) {
LOGGER.info(
"Error unmarshalling template output for MapML features "
+ "Output from template: "
+ templateOutput
+ " Error: "
+ e.getLocalizedMessage());
throw new ServiceException(e, templateOutput);
}
}

/**
* Append the CSS style from the template to the feature
*
* @param head the head content
* @param interpolated the interpolated object from the template
*/
private static void appendTemplateCSSStyle(HeadContent head, Mapml interpolated) {
if (head != null) {
if (interpolated.getHead() != null && interpolated.getHead().getStyle() != null) {
String interpolatedCSSStyle = interpolated.getHead().getStyle();
if (head.getStyle() == null) {
head.setStyle(interpolatedCSSStyle);
} else {
head.setStyle(head.getStyle() + " " + interpolatedCSSStyle);
}
}
}
}

private static Optional<Mapml> getInterpolatedStylesFromTemplate(SimpleFeatureCollection fc)
throws IOException {
String templateOutput = mapMLMapTemplate.featureHead(fc.getSchema());
StringReader reader = new StringReader(templateOutput);
try {
return Optional.of(encoder.decode(reader));
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Error unmarshalling template output: " + templateOutput, e);
throw new ServiceException(e, templateOutput);
}
}

/**
* Get an empty MapML document populated with basic request related metadata
*
Expand Down
Loading
Loading