Skip to content

Commit d303e8b

Browse files
vidakovicvelo
andauthored
Add support for Postgis JTS (#416)
* Add support for Postgis JTS * Return project build to java 11 --------- Co-authored-by: Marvin <[email protected]>
1 parent ebb438f commit d303e8b

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

.mvn/jvm.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
--illegal-access=permit
21
--add-opens jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
32
--add-opens jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
43
--add-opens jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED

querydsl-libraries/querydsl-sql-spatial/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@
9393
<version>2023.1.0</version>
9494
<optional>true</optional>
9595
</dependency>
96+
<dependency>
97+
<groupId>net.postgis</groupId>
98+
<artifactId>postgis-jdbc-jts</artifactId>
99+
<version>2023.1.0</version>
100+
<optional>true</optional>
101+
</dependency>
96102
<dependency>
97103
<groupId>com.oracle.database.jdbc</groupId>
98104
<artifactId>ojdbc8</artifactId>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2015, The Querydsl Team (http://www.querydsl.com/team)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.querydsl.sql.spatial;
15+
16+
import com.querydsl.sql.types.AbstractType;
17+
import java.sql.PreparedStatement;
18+
import java.sql.ResultSet;
19+
import java.sql.SQLException;
20+
import java.sql.Types;
21+
import net.postgis.jdbc.jts.JtsGeometry;
22+
import org.locationtech.jts.geom.Geometry;
23+
24+
class JtsGeometryType extends AbstractType<Geometry> {
25+
26+
public static final JtsGeometryType DEFAULT = new JtsGeometryType();
27+
28+
public JtsGeometryType() {
29+
super(Types.STRUCT);
30+
}
31+
32+
@Override
33+
public Class<Geometry> getReturnedClass() {
34+
return Geometry.class;
35+
}
36+
37+
@Override
38+
public Geometry getValue(ResultSet rs, int startIndex) throws SQLException {
39+
var value = rs.getObject(startIndex, JtsGeometry.class);
40+
return value.getGeometry();
41+
}
42+
43+
@Override
44+
public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException {
45+
st.setObject(startIndex, new JtsGeometry(value));
46+
}
47+
}

querydsl-libraries/querydsl-sql-spatial/src/main/java/com/querydsl/sql/spatial/PostGISTemplates.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public PostGISTemplates(boolean quote) {
4747
public PostGISTemplates(char escape, boolean quote) {
4848
super(escape, quote);
4949
addCustomType(PGgeometryType.DEFAULT);
50+
addCustomType(JtsGeometryType.DEFAULT);
5051
add(SpatialTemplatesSupport.getSpatialOps(true));
5152
add(SpatialOps.DISTANCE_SPHERE, "ST_Distance_Sphere({0}, {1})");
5253
add(SpatialOps.DISTANCE_SPHEROID, "ST_Distance_Spheroid({0}, {1})");

0 commit comments

Comments
 (0)