Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8097cce

Browse files
authored
Extract GeoTools Plugin and related modules (#456)
1 parent3748226 commit8097cce

File tree

66 files changed

+871
-571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+871
-571
lines changed

‎.github/workflows/release.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
-name:Upload all jars to Release
7373
uses:AButler/upload-release-assets@v3.0
7474
with:
75-
files:"**/target/*.jar"
75+
files:"**/target/*-with-dependencies.jar"
7676
repo-token:${{ secrets.GITHUB_TOKEN }}
7777
release-id:${{ steps.create_release.outputs.id }}
7878

‎cli-tools/pom.xml‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright (c) "Neo4j"
4+
~ Neo4j Sweden AB [http://neo4j.com]
5+
~
6+
~ This file is part of Neo4j Spatial.
7+
~
8+
~ Neo4j is free software: you can redistribute it and/or modify
9+
~ it under the terms of the GNU General Public License as published by
10+
~ the Free Software Foundation, either version 3 of the License, or
11+
~ (at your option) any later version.
12+
~
13+
~ This program is distributed in the hope that it will be useful,
14+
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
~ GNU General Public License for more details.
17+
~
18+
~ You should have received a copy of the GNU General Public License
19+
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-->
21+
22+
<projectxmlns="http://maven.apache.org/POM/4.0.0"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
25+
<modelVersion>4.0.0</modelVersion>
26+
<parent>
27+
<groupId>org.neo4j</groupId>
28+
<artifactId>neo4j-spatial</artifactId>
29+
<version>2025.10.1-SNAPSHOT</version>
30+
</parent>
31+
32+
<artifactId>neo4j-spatial-cli-tools</artifactId>
33+
34+
<dependencies>
35+
<dependency>
36+
<groupId>org.neo4j</groupId>
37+
<artifactId>neo4j-spatial-geotools-plugin</artifactId>
38+
<version>2025.10.1-SNAPSHOT</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.geotools</groupId>
42+
<artifactId>gt-shapefile</artifactId>
43+
<version>${geotools.version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.geotools</groupId>
47+
<artifactId>gt-xml</artifactId>
48+
<version>${geotools.version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.geotools</groupId>
52+
<artifactId>gt-render</artifactId>
53+
<version>${geotools.version}</version>
54+
<exclusions>
55+
<exclusion>
56+
<groupId>it.geosolutions.imageio-ext</groupId>
57+
<artifactId>imageio-ext-tiff</artifactId>
58+
</exclusion>
59+
</exclusions>
60+
</dependency>
61+
</dependencies>
62+
</project>

server-plugin/src/main/java/org/neo4j/gis/spatial/osm/OSMLayerToShapefileExporter.java renamed to cli-tools/src/main/java/org/neo4j/spatial/cli/tools/OSMLayerToShapefileExporter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717
* You should have received a copy of the GNU General Public License
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
20-
packageorg.neo4j.gis.spatial.osm;
20+
packageorg.neo4j.spatial.cli.tools;
2121

2222
importjava.io.File;
2323
importjava.util.ArrayList;
2424
importjava.util.Arrays;
2525
importjava.util.List;
2626
importjava.util.logging.Logger;
27-
importorg.geotools.data.neo4j.Neo4jSpatialDataStore;
2827
importorg.neo4j.driver.AuthTokens;
2928
importorg.neo4j.driver.GraphDatabase;
30-
importorg.neo4j.gis.spatial.ShapefileExporter;
29+
importorg.neo4j.spatial.geotools.plugin.Neo4jSpatialDataStore;
3130

3231
publicclassOSMLayerToShapefileExporter {
3332

server-plugin/src/main/java/org/neo4j/gis/spatial/ShapefileExporter.java renamed to cli-tools/src/main/java/org/neo4j/spatial/cli/tools/ShapefileExporter.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* You should have received a copy of the GNU General Public License
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
20-
packageorg.neo4j.gis.spatial;
20+
packageorg.neo4j.spatial.cli.tools;
2121

2222
importjava.io.File;
2323
importjava.io.Serializable;
@@ -29,10 +29,10 @@
2929
importorg.geotools.api.feature.simple.SimpleFeatureType;
3030
importorg.geotools.api.feature.type.GeometryDescriptor;
3131
importorg.geotools.api.referencing.crs.CoordinateReferenceSystem;
32-
importorg.geotools.data.neo4j.Neo4jSpatialDataStore;
3332
importorg.geotools.data.shapefile.ShapefileDataStore;
3433
importorg.geotools.data.shapefile.ShapefileDataStoreFactory;
3534
importorg.neo4j.driver.Driver;
35+
importorg.neo4j.spatial.geotools.plugin.Neo4jSpatialDataStore;
3636

3737
publicclassShapefileExporter {
3838

@@ -89,7 +89,6 @@ public File exportLayer(String layerName, File file) throws Exception {
8989
SimpleFeatureTypefeatureType =neo4jDataStore.getSchema(layerName);
9090
GeometryDescriptorgeometryType =featureType.getGeometryDescriptor();
9191
crs =geometryType.getCoordinateReferenceSystem();
92-
// crs = neo4jDataStore.getFeatureSource(layerName).getInfo().getCRS();
9392

9493
shpDataStore.createSchema(featureType);
9594
if (shpDataStore.getFeatureSource()instanceofSimpleFeatureStorestore) {

server-plugin/src/main/java/org/geotools/data/neo4j/StyledImageExporter.java renamed to cli-tools/src/main/java/org/neo4j/spatial/cli/tools/StyledImageExporter.java

Lines changed: 6 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* You should have received a copy of the GNU General Public License
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
20-
packageorg.geotools.data.neo4j;
20+
packageorg.neo4j.spatial.cli.tools;
2121

2222
importstaticjava.awt.RenderingHints.KEY_ANTIALIASING;
2323
importstaticjava.awt.RenderingHints.KEY_TEXT_ANTIALIASING;
@@ -28,47 +28,28 @@
2828
importjava.awt.image.BufferedImage;
2929
importjava.io.File;
3030
importjava.io.IOException;
31-
importjava.util.logging.Level;
3231
importjava.util.logging.Logger;
3332
importjavax.imageio.ImageIO;
3433
importorg.geotools.api.data.DataStore;
3534
importorg.geotools.api.data.SimpleFeatureStore;
3635
importorg.geotools.api.feature.simple.SimpleFeature;
3736
importorg.geotools.api.feature.simple.SimpleFeatureType;
38-
importorg.geotools.api.feature.type.FeatureType;
39-
importorg.geotools.api.filter.FilterFactory;
40-
importorg.geotools.api.style.FeatureTypeStyle;
41-
importorg.geotools.api.style.Fill;
42-
importorg.geotools.api.style.Graphic;
43-
importorg.geotools.api.style.LineSymbolizer;
44-
importorg.geotools.api.style.Mark;
45-
importorg.geotools.api.style.PointSymbolizer;
46-
importorg.geotools.api.style.PolygonSymbolizer;
47-
importorg.geotools.api.style.Rule;
48-
importorg.geotools.api.style.Stroke;
4937
importorg.geotools.api.style.Style;
5038
importorg.geotools.api.style.StyleFactory;
5139
importorg.geotools.data.DefaultTransaction;
5240
importorg.geotools.factory.CommonFactoryFinder;
5341
importorg.geotools.feature.FeatureCollection;
54-
importorg.geotools.filter.text.cql2.CQLException;
55-
importorg.geotools.filter.text.ecql.ECQL;
5642
importorg.geotools.geometry.jts.ReferencedEnvelope;
5743
importorg.geotools.map.FeatureLayer;
5844
importorg.geotools.map.MapContent;
5945
importorg.geotools.renderer.lite.StreamingRenderer;
6046
importorg.geotools.xml.styling.SLDParser;
61-
importorg.locationtech.jts.geom.LineString;
62-
importorg.locationtech.jts.geom.LinearRing;
63-
importorg.locationtech.jts.geom.MultiLineString;
64-
importorg.locationtech.jts.geom.MultiPoint;
65-
importorg.locationtech.jts.geom.MultiPolygon;
66-
importorg.locationtech.jts.geom.Point;
67-
importorg.locationtech.jts.geom.Polygon;
6847
importorg.neo4j.driver.AuthTokens;
6948
importorg.neo4j.driver.Driver;
7049
importorg.neo4j.driver.GraphDatabase;
71-
importorg.neo4j.gis.spatial.SpatialTopologyUtils;
50+
importorg.neo4j.spatial.geotools.common.utilities.GeotoolsUtils;
51+
importorg.neo4j.spatial.geotools.common.utilities.RenderingUtils;
52+
importorg.neo4j.spatial.geotools.plugin.Neo4jSpatialDataStore;
7253

7354
publicclassStyledImageExporter {
7455

@@ -81,7 +62,6 @@ public class StyledImageExporter {
8162
RectangledisplaySize =newRectangle(400,300);
8263
privateString[]styleFiles;
8364
staticfinalStyleFactorystyleFactory =CommonFactoryFinder.getStyleFactory(null);
84-
staticfinalFilterFactoryfilterFactory =CommonFactoryFinder.getFilterFactory(null);
8565

8666
publicStyledImageExporter(Driverdriver,Stringdatabase) {
8767
this.driver =driver;
@@ -220,7 +200,7 @@ public void saveLayerImage(String[] layerNames, String sldFile, File imagefile,
220200
}
221201

222202
if (featureStyle ==null) {
223-
featureStyle =createStyleFromGeometry(featureSource.getSchema(),Color.BLUE,
203+
featureStyle =RenderingUtils.createStyleFromGeometry(featureSource.getSchema(),Color.BLUE,
224204
Color.CYAN);
225205
LOGGER.info("Created style from geometry '" +
226206
featureSource.getSchema().getGeometryDescriptor()
@@ -254,7 +234,7 @@ private static Style getStyleFromSLDFile(String sldFile) {
254234

255235
privatevoidsaveMapContentToImageFile(MapContentmapContent,Fileimagefile,ReferencedEnvelopebounds)
256236
throwsIOException {
257-
bounds =SpatialTopologyUtils.adjustBounds(bounds,1.0 /zoom,offset);
237+
bounds =GeotoolsUtils.adjustBounds(bounds,1.0 /zoom,offset);
258238

259239
if (displaySize ==null) {
260240
displaySize =newRectangle(0,0,800,600);
@@ -291,151 +271,6 @@ private static Style createStyleFromSLD(String sldFile) {
291271
returnnull;
292272
}
293273

294-
publicstaticStylecreateDefaultStyle(ColorstrokeColor,ColorfillColor) {
295-
returncreateStyleFromGeometry(null,strokeColor,fillColor);
296-
}
297-
298-
/**
299-
* Here is a programmatic alternative to using JSimpleStyleDialog to
300-
* get a Style. These methods works out what sort of feature geometry
301-
* we have in the shapefile and then delegates to an appropriate style
302-
* creating method.
303-
* <a href="https://docs.geotools.org/stable/userguide/examples/stylefunctionlab.html">stylefunctionlab</a>
304-
*/
305-
// TODO: Consider adding support for attribute based color schemes like in
306-
publicstaticStylecreateStyleFromGeometry(FeatureTypeschema,ColorstrokeColor,ColorfillColor) {
307-
if (schema !=null) {
308-
Class<?>geomType =schema.getGeometryDescriptor().getType().getBinding();
309-
if (Polygon.class.isAssignableFrom(geomType)
310-
||MultiPolygon.class.isAssignableFrom(geomType)) {
311-
returncreatePolygonStyle(strokeColor,fillColor);
312-
}
313-
if (LineString.class.isAssignableFrom(geomType)
314-
||LinearRing.class.isAssignableFrom(geomType)
315-
||MultiLineString.class.isAssignableFrom(geomType)) {
316-
returncreateLineStyle(strokeColor);
317-
}
318-
if (Point.class.isAssignableFrom(geomType)
319-
||MultiPoint.class.isAssignableFrom(geomType)) {
320-
returncreatePointStyle(strokeColor,fillColor);
321-
}
322-
}
323-
324-
Stylestyle =styleFactory.createStyle();
325-
style.featureTypeStyles().addAll(createPolygonStyle(strokeColor,fillColor).featureTypeStyles());
326-
style.featureTypeStyles().addAll(createLineStyle(strokeColor).featureTypeStyles());
327-
style.featureTypeStyles().addAll(createPointStyle(strokeColor,fillColor).featureTypeStyles());
328-
returnstyle;
329-
}
330-
331-
/**
332-
* Create a Style to draw polygon features
333-
*/
334-
publicstaticStylecreatePolygonStyle(ColorstrokeColor,ColorfillColor) {
335-
returncreatePolygonStyle(strokeColor,fillColor,0.5,0.5,1);
336-
}
337-
338-
/**
339-
* Create a Style to draw polygon features
340-
*/
341-
publicstaticStylecreatePolygonStyle(ColorstrokeColor,ColorfillColor,doublestokeGamma,doublefillGamma,
342-
intstrokeWidth) {
343-
// create a partially opaque outline stroke
344-
Strokestroke =styleFactory.createStroke(
345-
filterFactory.literal(strokeColor),
346-
filterFactory.literal(strokeWidth),
347-
filterFactory.literal(stokeGamma));
348-
349-
// create a partial opaque fill
350-
Fillfill =styleFactory.createFill(
351-
filterFactory.literal(fillColor),
352-
filterFactory.literal(fillGamma));
353-
354-
/*
355-
* Setting the geometryPropertyName arg to null signals that we want to
356-
* draw the default geomettry of features
357-
*/
358-
PolygonSymbolizersym =styleFactory.createPolygonSymbolizer(stroke,fill,null);
359-
360-
Rulerule =styleFactory.createRule();
361-
rule.symbolizers().add(sym);
362-
try {
363-
rule.setFilter(ECQL.toFilter("geometryType(the_geom)='Polygon' or geometryType(the_geom)='MultiPoligon'"));
364-
}catch (CQLExceptione) {
365-
LOGGER.log(Level.WARNING,"",e);
366-
}
367-
368-
FeatureTypeStylefts =styleFactory.createFeatureTypeStyle(rule);
369-
Stylestyle =styleFactory.createStyle();
370-
style.featureTypeStyles().add(fts);
371-
372-
returnstyle;
373-
}
374-
375-
/**
376-
* Create a Style to draw line features
377-
*/
378-
privatestaticStylecreateLineStyle(ColorstrokeColor) {
379-
Strokestroke =styleFactory.createStroke(
380-
filterFactory.literal(strokeColor),
381-
filterFactory.literal(1));
382-
383-
/*
384-
* Setting the geometryPropertyName arg to null signals that we want to
385-
* draw the default geomettry of features
386-
*/
387-
LineSymbolizersym =styleFactory.createLineSymbolizer(stroke,null);
388-
389-
Rulerule =styleFactory.createRule();
390-
rule.symbolizers().add(sym);
391-
try {
392-
rule.setFilter(ECQL.toFilter(
393-
"geometryType(the_geom)='LineString' or geometryType(the_geom)='LinearRing' or geometryType(the_geom)='MultiLineString'"));
394-
}catch (CQLExceptione) {
395-
LOGGER.log(Level.WARNING,"",e);
396-
}
397-
398-
FeatureTypeStylefts =styleFactory.createFeatureTypeStyle(rule);
399-
Stylestyle =styleFactory.createStyle();
400-
style.featureTypeStyles().add(fts);
401-
402-
returnstyle;
403-
}
404-
405-
/**
406-
* Create a Style to draw point features as circles with blue outlines
407-
* and cyan fill
408-
*/
409-
privatestaticStylecreatePointStyle(ColorstrokeColor,ColorfillColor) {
410-
Markmark =styleFactory.getCircleMark();
411-
mark.setStroke(styleFactory.createStroke(filterFactory.literal(strokeColor),filterFactory.literal(2)));
412-
mark.setFill(styleFactory.createFill(filterFactory.literal(fillColor)));
413-
414-
Graphicgr =styleFactory.createDefaultGraphic();
415-
gr.graphicalSymbols().clear();
416-
gr.graphicalSymbols().add(mark);
417-
gr.setSize(filterFactory.literal(5));
418-
419-
/*
420-
* Setting the geometryPropertyName arg to null signals that we want to
421-
* draw the default geomettry of features
422-
*/
423-
PointSymbolizersym =styleFactory.createPointSymbolizer(gr,null);
424-
425-
Rulerule =styleFactory.createRule();
426-
rule.symbolizers().add(sym);
427-
try {
428-
rule.setFilter(ECQL.toFilter("geometryType(the_geom)='Point' or geometryType(the_geom)='MultiPoint'"));
429-
}catch (CQLExceptione) {
430-
LOGGER.log(Level.WARNING,"",e);
431-
}
432-
433-
FeatureTypeStylefts =styleFactory.createFeatureTypeStyle(rule);
434-
Stylestyle =styleFactory.createStyle();
435-
style.featureTypeStyles().add(fts);
436-
437-
returnstyle;
438-
}
439274

440275
publicstaticvoidmain(String[]args)throwsIOException {
441276
if (args.length <6) {
36.5 KB
Loading
Binary file not shown.
-32.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp