forked from geonetwork/core-geonetwork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API / Extent / Add records/uuid/extent.json to list record extents an…
…d add extent/0.png for returning only one (geonetwork#4930) * refactor * nominal test * testing for if-modified-since * refactor * testing with two extents * make the tests run * refactor * getting third extent polygon * also returning bouding box alone * polygons preferred over bounding boxes * refactor * seems that gml parser are not thread safe * minor doc changes (geonetwork#4923) Co-authored-by: david blasby <[email protected]> * API / Extent / Allow to request only one geometry Operation `GET /api/records{metadataUuid}/extents.json` return a list of available extent. ```json [ { href: "http://localhost:8080/geonetwork/srv/api/records/9fa0dbe1-1a0d-4fbb-86ad-e7729b9697d4/extents.png", type: "ALL", xpath: "", description: "" }, { href: "http://localhost:8080/geonetwork/srv/api/records/9fa0dbe1-1a0d-4fbb-86ad-e7729b9697d4/extents/1.png", type: "EX_GeographicBoundingBox", xpath: "/mdb:MD_Metadata/mdb:identificationInfo/mri:MD_DataIdentification/mri:extent[2]/gex:EX_Extent/gex:geographicElement/gex:EX_GeographicBoundingBox", description: "Planet earth" }, { href: "http://localhost:8080/geonetwork/srv/api/records/9fa0dbe1-1a0d-4fbb-86ad-e7729b9697d4/extents/2.png", type: "EX_GeographicBoundingBox", xpath: "/mdb:MD_Metadata/mdb:identificationInfo/mri:MD_DataIdentification/mri:extent[3]/gex:EX_Extent/gex:geographicElement[1]/gex:EX_GeographicBoundingBox", description: "" }, { href: "http://localhost:8080/geonetwork/srv/api/records/9fa0dbe1-1a0d-4fbb-86ad-e7729b9697d4/extents/3.png", type: "EX_BoundingPolygon", xpath: "/mdb:MD_Metadata/mdb:identificationInfo/mri:MD_DataIdentification/mri:extent[3]/gex:EX_Extent/gex:geographicElement[2]/gex:EX_BoundingPolygon", description: "" }, { href: "http://localhost:8080/geonetwork/srv/api/records/9fa0dbe1-1a0d-4fbb-86ad-e7729b9697d4/extents/4.png", type: "EX_GeographicBoundingBox", xpath: "/mdb:MD_Metadata/mdb:identificationInfo/mri:MD_DataIdentification/mri:extent[3]/gex:EX_Extent/gex:geographicElement[3]/gex:EX_GeographicBoundingBox", description: "" } ] ``` Operation `GET /api/records{metadataUuid}/extents.png` return all extents combined in one image (same as before). Operation `GET /api/records{metadataUuid}/extents/{extentIndex}.json` return the requested extent. The extent can be a bounding box or a bounding polygon. This is only supported for ISO19139 and ISO19115-3 standards. * API / Extent / Allow to request only one geometry - A bit more robust for schema not having geometry. * refactor * refactor, rename test * to be sure * Revert "minor doc changes (geonetwork#4923)" This reverts commit 895ceb5. * gml parser not thread-safe * systematically create gml parser when one needed * refactor * use map renderer for pdf generation so not to have credential to give * fix tests * API / Extent / Formatters / XSL / Display all geometry separately. Preserve order of XML for all geographicElement. * API / Extent / Formatters / XSL / Display all geometry separately. Preserve order of XML for all geographicElement. * API / Extent / Fix projection when requesting one polygon. * API / Extent / Fix test with correct coordinates - added overview image to check file on disk. * editor: handle invalid srsName for geometry edit panel * editor: surround gml geom with gmd:polygon on directive load * update ol - urn:x-ogc:def:crs:EPSG:6.6:4326 Co-authored-by: davidblasby <[email protected]> Co-authored-by: david blasby <[email protected]> Co-authored-by: Francois Prunayre <[email protected]> Co-authored-by: Florent gravin <[email protected]>
- Loading branch information
1 parent
74f655e
commit c5be401
Showing
32 changed files
with
2,173 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
package org.fao.geonet.util; | ||
|
||
import org.fao.geonet.constants.Geonet; | ||
import org.geotools.gml3.GMLConfiguration; | ||
import org.geotools.xsd.Configuration; | ||
import org.geotools.xsd.Parser; | ||
import org.jdom.Element; | ||
|
||
public final class GMLParsers { | ||
public static Parser[] create() { | ||
Parser[] parsers = { | ||
new Parser(new GMLConfiguration()), | ||
new Parser(new org.geotools.gml3.v3_2.GMLConfiguration()) | ||
}; | ||
return parsers; | ||
} | ||
|
||
private GMLParsers() {} | ||
|
||
private static final GMLConfiguration GML_CONFIGURATION = new GMLConfiguration(); | ||
private static final org.geotools.gml3.v3_2.GMLConfiguration GML_32_CONFIGURATION = new org.geotools.gml3.v3_2.GMLConfiguration(); | ||
|
||
static public Parser create(Element geom) { | ||
if (geom.getNamespace().equals(Geonet.Namespaces.GML32)) { | ||
return createGML32(); | ||
} else { | ||
return createGML(); | ||
} | ||
} | ||
|
||
static private Parser createGML32() { | ||
return createParser(GML_32_CONFIGURATION); | ||
} | ||
|
||
public static Parser createGML() { | ||
return createParser(GML_CONFIGURATION); | ||
} | ||
|
||
static private Parser createParser(Configuration configuration) { | ||
Parser parser = new Parser(configuration); | ||
parser.setStrict(false); | ||
parser.setValidating(false); | ||
return parser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
core/src/test/java/org/fao/geonet/util/GMLParserLearnTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.fao.geonet.util; | ||
|
||
import org.fao.geonet.utils.Xml; | ||
import org.geotools.xsd.Parser; | ||
import org.jdom.JDOMException; | ||
import org.junit.Test; | ||
import org.xml.sax.SAXException; | ||
|
||
import javax.xml.parsers.ParserConfigurationException; | ||
import java.io.IOException; | ||
import java.io.StringReader; | ||
import java.net.URL; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
import static org.fao.geonet.schema.iso19139.ISO19139Namespaces.GCO; | ||
import static org.fao.geonet.schema.iso19139.ISO19139Namespaces.GMD; | ||
import static org.fao.geonet.schema.iso19139.ISO19139Namespaces.GML; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
public class GMLParserLearnTest { | ||
|
||
static final String TO_PARSE; | ||
|
||
static { | ||
URL resource = GMLParserLearnTest.class.getResource("../kernel/multilingual-metadata.xml"); | ||
String toParse; | ||
try { | ||
toParse = Xml.getString(Xml.selectElement( Xml.loadStream(resource.openStream()), ".//gmd:polygon", Arrays.asList(GMD, GCO, GML))); | ||
} catch (Exception e) { | ||
toParse = null; | ||
e.printStackTrace(); | ||
} | ||
TO_PARSE = toParse; | ||
} | ||
|
||
|
||
@Test | ||
public void geotoolsGmlParserNotThreadSafe() throws IOException, JDOMException, ParserConfigurationException, SAXException, InterruptedException { | ||
final Parser parser = GMLParsers.createGML(); | ||
parser.parse(new StringReader(TO_PARSE)); | ||
|
||
IntStream range = IntStream.rangeClosed(1, 20); | ||
List<Object> failedParseNew = range.parallel().mapToObj(GMLParserLearnTest::parseCreateNewParser).filter(x -> x == null).collect(Collectors.toList()); | ||
assertEquals(0, failedParseNew.size()); | ||
|
||
range = IntStream.rangeClosed(1, 20); | ||
List<Object> failedParseReuse = range.parallel().mapToObj(GMLParserLearnTest::parseResuseParser).filter(x -> x == null).collect(Collectors.toList()); | ||
assertNotEquals(0, failedParseReuse.size()); | ||
|
||
} | ||
|
||
static private Object parseCreateNewParser(int inc) { | ||
Parser parser = GMLParsers.createGML(); | ||
try { | ||
return parser.parse(new StringReader(TO_PARSE)); | ||
} catch (Exception e) { | ||
//e.printStackTrace(); | ||
return null; | ||
} | ||
|
||
} | ||
|
||
static private Parser parserToReuse = GMLParsers.createGML(); | ||
|
||
static private Object parseResuseParser(int inc) { | ||
try { | ||
return parserToReuse.parse(new StringReader(TO_PARSE)); | ||
} catch (Exception e) { | ||
//e.printStackTrace(); | ||
return null; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.