Skip to content

Commit

Permalink
[GEOS-11299] Performance regression in GeoJSON output generated in EP…
Browse files Browse the repository at this point in the history
…SG:900913
  • Loading branch information
aaime committed Feb 9, 2024
1 parent 2512136 commit ff4ec92
Show file tree
Hide file tree
Showing 36 changed files with 82 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.io.IOException;
import java.math.BigInteger;
import java.util.List;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.featurestemplating.builders.EncodingHints;
import org.geotools.api.referencing.FactoryException;
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
Expand Down Expand Up @@ -208,7 +209,7 @@ protected static String getCRSIdentifier(CoordinateReferenceSystem crs) throws I
identifier = SrsSyntax.OGC_URN.getPrefix() + code;
}
} else {
identifier = CRS.lookupIdentifier(crs, true);
identifier = ResourcePool.lookupIdentifier(crs, true);
}
return identifier;
} catch (FactoryException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.geoserver.catalog.NamespaceInfo;
import org.geoserver.catalog.PublishedInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.catalog.StyleInfo;
import org.geoserver.catalog.WorkspaceInfo;
import org.geoserver.config.GeoServer;
Expand Down Expand Up @@ -324,7 +325,7 @@ private Object getCommaSeparated(Envelope bbox) {

private String getFirstCRS(List<PublishedInfo> layers) {
try {
return CRS.lookupIdentifier(getCRS(layers.get(0)), false);
return ResourcePool.lookupIdentifier(getCRS(layers.get(0)), false);
} catch (FactoryException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.DimensionInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.config.GeoServer;
import org.geoserver.crs.CapabilitiesCRSProvider;
import org.geoserver.ogcapi.APIBBoxParser;
Expand Down Expand Up @@ -317,7 +318,7 @@ public static String getCRSURI(CoordinateReferenceSystem crs) throws FactoryExce
if (CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) {
return DEFAULT_CRS;
}
String identifier = CRS.lookupIdentifier(crs, false);
String identifier = ResourcePool.lookupIdentifier(crs, false);
return mapResponseSRS(identifier);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.commons.io.IOUtils;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.FeatureTypeInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.config.GeoServer;
import org.geoserver.crs.CapabilitiesCRSProvider;
import org.geoserver.ogcapi.APIBBoxParser;
Expand Down Expand Up @@ -167,7 +168,7 @@ public static String getCRSURI(CoordinateReferenceSystem crs) throws FactoryExce
if (CRS.equalsIgnoreMetadata(crs, DefaultGeographicCRS.WGS84)) {
return FeatureService.DEFAULT_CRS;
}
String identifier = CRS.lookupIdentifier(crs, false);
String identifier = ResourcePool.lookupIdentifier(crs, false);
return mapResponseSRS(identifier);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.PublishedInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.catalog.StyleInfo;
import org.geoserver.config.GeoServer;
import org.geoserver.ogcapi.APIBBoxParser;
Expand All @@ -45,7 +46,6 @@
import org.geoserver.wms.WebMapService;
import org.geotools.api.referencing.FactoryException;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -191,7 +191,7 @@ public WebMap map(
if ("text/html".equals(format) || "html".equals(format)) {
DefaultWebMapService.autoSetBoundsAndSize(request);
if (request.getCrs() != null)
request.setSRS(CRS.lookupIdentifier(request.getCrs(), false));
request.setSRS(ResourcePool.lookupIdentifier(request.getCrs(), false));
request.getRawKvp().put("width", String.valueOf(request.getWidth()));
request.getRawKvp().put("height", String.valueOf(request.getHeight()));
if (height != null) request.setHeight(height);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.catalog.StyleHandler;
import org.geoserver.catalog.Styles;
import org.geoserver.importer.job.ProgressMonitor;
Expand All @@ -35,8 +36,6 @@ public class SpatialFile extends FileData {

private static final long serialVersionUID = -280215815681792790L;

static EPSGCodeLookupCache EPSG_LOOKUP_CACHE = new EPSGCodeLookupCache();

/** .prj file */
File prjFile;

Expand Down Expand Up @@ -169,7 +168,7 @@ public void fixPrjFile() throws IOException {

try {
CoordinateReferenceSystem epsgCrs = null;
String identifier = EPSG_LOOKUP_CACHE.lookupIdentifier(crs);
String identifier = ResourcePool.lookupIdentifier(crs, true);
if (identifier != null) {
epsgCrs = CRS.decode(SrsSyntax.AUTH_CODE.getSRS(identifier));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package org.geoserver.importer.transform;

import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.importer.ImportTask;
import org.geotools.api.data.DataStore;
import org.geotools.api.feature.simple.SimpleFeature;
Expand Down Expand Up @@ -56,7 +57,7 @@ public SimpleFeatureType apply(
// update the layer metadata
ResourceInfo r = task.getLayer().getResource();
r.setNativeCRS(target);
r.setSRS(CRS.lookupIdentifier(target, true));
r.setSRS(ResourcePool.lookupIdentifier(target, true));
if (r.getNativeBoundingBox() != null) {
r.setNativeBoundingBox(r.getNativeBoundingBox().transform(target, true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.DimensionInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.ows.util.ResponseUtils;
import org.geoserver.platform.OWS20Exception.OWSExceptionCode;
import org.geoserver.wcs.WCSInfo;
Expand Down Expand Up @@ -271,7 +272,7 @@ private void encodeDatasetBounds(CoverageInfo ci, GridCoverage2DReader reader)
// lookup EPSG code
String crsId = null;
try {
crsId = CRS.lookupIdentifier(crs, true);
crsId = ResourcePool.lookupIdentifier(crs, true);
} catch (FactoryException e) {
throw new IllegalStateException(
"Unable to lookup epsg code for this CRS:" + crs, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.geoserver.catalog.CoverageInfo;
import org.geoserver.catalog.DimensionInfo;
import org.geoserver.catalog.ResourceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.config.GeoServer;
import org.geoserver.ows.URLMangler.URLType;
import org.geoserver.ows.util.ResponseUtils;
Expand Down Expand Up @@ -225,7 +226,7 @@ private String posList(double... ordinates) {
private String getSRSName(CoordinateReferenceSystem crs) {
String crsId = null;
try {
crsId = CRS.lookupIdentifier(crs, true);
crsId = ResourcePool.lookupIdentifier(crs, true);
} catch (FactoryException e) {
throw new IllegalStateException("Unable to lookup epsg code for this CRS:" + crs, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.stream.Collectors;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.Predicates;
import org.geoserver.catalog.ResourcePool;
import org.geotools.api.data.Query;
import org.geotools.api.feature.simple.SimpleFeature;
import org.geotools.api.feature.type.GeometryDescriptor;
Expand Down Expand Up @@ -280,7 +281,7 @@ private SimpleFeature getFirstGranuleMatchingCRS(
// since they can expose a crs attribute
return null;
}
String crsId = CRS.lookupIdentifier(targetCRS, false);
String crsId = ResourcePool.lookupIdentifier(targetCRS, false);
if (crsId == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.imageio.ImageIO;
import javax.imageio.stream.MemoryCacheImageInputStream;
import javax.media.jai.PlanarImage;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.config.GeoServer;
import org.geoserver.kml.KMLEncoder;
import org.geoserver.kml.KmlEncodingContext;
Expand Down Expand Up @@ -407,7 +408,7 @@ private RenderedImage buildImageInternal(
throw new WPSException("The BBOX parameter must have a coordinate reference system");
} else {
// handle possible axis flipping by changing the WMS version accordingly
String code = CRS.lookupIdentifier(crs, false);
String code = ResourcePool.lookupIdentifier(crs, false);
if (CRS.getAxisOrder(crs) == CRS.AxisOrder.EAST_NORTH) {
template.put("version", "1.1.0");
template.put("srs", SrsSyntax.AUTH_CODE.getSRS(code));
Expand Down Expand Up @@ -590,7 +591,7 @@ private RenderedImage getImageFromWebMapServer(

// check version, if we are using 1.3 we might need to flip the bbox, if version 1.1 and the
// original bbox was flipped, we'll need to un-flip (what a mess...)
String crsId = CRS.lookupIdentifier(bbox.getCoordinateReferenceSystem(), true);
String crsId = ResourcePool.lookupIdentifier(bbox.getCoordinateReferenceSystem(), true);
CoordinateReferenceSystem epsgOrderCrs = CRS.decode(SrsSyntax.OGC_URN.getSRS(crsId));
CRS.AxisOrder axisOrder = CRS.getAxisOrder(epsgOrderCrs);
getMap.setSRS(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.xml.transform.sax.SAXResult;
import org.geoserver.catalog.Catalog;
import org.geoserver.catalog.NamespaceInfo;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.wps.web.InputParameterValues.ParameterType;
import org.geoserver.wps.web.InputParameterValues.ParameterValue;
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
Expand All @@ -26,7 +27,6 @@
import org.geotools.gml2.bindings.GML2EncodingUtils;
import org.geotools.gml3.GML;
import org.geotools.ows.v1_1.OWS;
import org.geotools.referencing.CRS;
import org.geotools.util.Converters;
import org.geotools.util.logging.Logging;
import org.geotools.wps.WPS;
Expand Down Expand Up @@ -177,7 +177,7 @@ public void handleInputs(List<InputParameterValues> inputs) {
CoordinateReferenceSystem crs = env.getCoordinateReferenceSystem();
if (crs != null) {
try {
crsId = CRS.lookupIdentifier(crs, false);
crsId = ResourcePool.lookupIdentifier(crs, false);
} catch (Exception e) {
LOGGER.log(Level.WARNING, "Could not get EPSG code for " + crsId);
}
Expand Down Expand Up @@ -231,7 +231,7 @@ private void handleCoordinateReferenceSystem(ParameterValue value) {
try {
start("wps:Data");
final CoordinateReferenceSystem crs = (CoordinateReferenceSystem) value.value;
element("wps:LiteralData", CRS.lookupIdentifier(crs, false));
element("wps:LiteralData", ResourcePool.lookupIdentifier(crs, false));
end("wps:Data");
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import javax.media.jai.JAI;
import javax.media.jai.operator.ConstantDescriptor;
import org.apache.commons.io.IOUtils;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.wps.WPSException;
import org.geoserver.wps.resource.WPSFileResource;
import org.geoserver.wps.resource.WPSResourceManager;
Expand All @@ -51,7 +52,6 @@
import org.geotools.process.factory.DescribeProcess;
import org.geotools.process.factory.DescribeResult;
import org.geotools.process.factory.DescribeResults;
import org.geotools.referencing.CRS;
import org.geotools.util.Utilities;
import org.geotools.util.logging.Logging;
import org.locationtech.jts.geom.Envelope;
Expand Down Expand Up @@ -473,7 +473,7 @@ private static List<String> parseBBox(Envelope re) {
private static String parseCrs(CoordinateReferenceSystem crs) {
Utilities.ensureNonNull("coordinateReferenceSystem", crs);
try {
return CRS.lookupIdentifier(crs, true);
return ResourcePool.lookupIdentifier(crs, true);
} catch (FactoryException e) {
throw new WPSException("Error occurred looking up target SRS");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.geoserver.catalog.FeatureTypeInfo;
import org.geoserver.catalog.LayerInfo;
import org.geoserver.catalog.ProjectionPolicy;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.catalog.StoreInfo;
import org.geoserver.catalog.StyleInfo;
import org.geoserver.catalog.WorkspaceInfo;
Expand Down Expand Up @@ -321,7 +322,7 @@ private String importCoverage(
CoordinateReferenceSystem cvCrs = coverage.getCoordinateReferenceSystem();
if (srs != null) {
try {
String code = CRS.lookupIdentifier(srs, true);
String code = ResourcePool.lookupIdentifier(srs, true);
if (code == null) {
throw new WPSException("Could not find a EPSG code for " + srs);
}
Expand Down Expand Up @@ -588,7 +589,7 @@ private String importFeatures(
private static String getSRSFromCRS(CoordinateReferenceSystem nativeCrs) {
String targetSRSCode;
try {
String identifier = CRS.lookupIdentifier(nativeCrs, true);
String identifier = ResourcePool.lookupIdentifier(nativeCrs, true);
if (identifier == null) {
throw new ProcessException(
"Could not find an EPSG identifier for data "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.stream.Collectors;
import net.opengis.ows11.BoundingBoxType;
import net.opengis.ows11.Ows11Factory;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.wps.WPSException;
import org.geotools.api.geometry.BoundingBox;
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
Expand Down Expand Up @@ -119,7 +120,7 @@ BoundingBoxType fromTargetType(Object object) throws WPSException {
// handle the EPSG code
if (crs != null) {
try {
bbox.setCrs(CRS.lookupIdentifier(crs, false));
bbox.setCrs(ResourcePool.lookupIdentifier(crs, false));
} catch (Exception e) {
throw new WPSException("Could not lookup epsg code for " + crs, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package org.geoserver.wps.ppio;

import org.geoserver.catalog.ResourcePool;
import org.geotools.api.referencing.crs.CoordinateReferenceSystem;
import org.geotools.referencing.CRS;

Expand Down Expand Up @@ -34,6 +35,6 @@ public String encode(Object value) throws Exception {
if (value == null) {
return null;
}
return CRS.lookupIdentifier(((CoordinateReferenceSystem) value), true);
return ResourcePool.lookupIdentifier(((CoordinateReferenceSystem) value), true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.opengis.wfs.FeatureCollectionType;
import net.opengis.wfs.WfsFactory;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.geoserver.catalog.ResourcePool;
import org.geoserver.feature.RetypingFeatureCollection;
import org.geotools.api.feature.simple.SimpleFeature;
import org.geotools.api.feature.simple.SimpleFeatureType;
Expand Down Expand Up @@ -108,7 +109,7 @@ public Object decode(Object input) throws Exception {
}

// we assume the crs has a valid identity
String identifier = CRS.lookupIdentifier(crs, false);
String identifier = ResourcePool.lookupIdentifier(crs, false);
if (identifier != null) {
String eastNorthId = SrsSyntax.AUTH_CODE.getSRS(identifier);
CoordinateReferenceSystem lonLatCrs = CRS.decode(eastNorthId, true);
Expand Down
Loading

0 comments on commit ff4ec92

Please sign in to comment.