jdeolive / geodb Goto Github PK
View Code? Open in Web Editor NEWSpatial database bindings for Java.
License: MIT License
Spatial database bindings for Java.
License: MIT License
currently reading a bounding box involves deserializing the entire geometry
Since this commit (http://github.com/jdeolive/geodb/commit/9f70fd1152f83df3fd2725ae4fb919e881299791) the JTS library was updated to version 1.12-SNAPSHOT. However, with my Maven configuration the artifact cannot be found.
In InitGeoDB, the geometry_columns table is created with the following column order:
f_table_name, f_geometry_column, coord_dimension, srid, type
However, in AddGeometryColumn, new entries are inserted with the srid and coord_dimension columns switched, so that the SRID ends up in the dimension column, and vice-versa.
Download link doesn't work, please update it
Can you release this so we can depend on repository that is listed on https://docs.geotools.org/stable/userguide/build/maven/repositories.html?
Is this project still maintained? H2 version is quite old, plus there it's not available in Maven Central which is the most used repository.
Would it be possible to get a new release? I am working on spatial support in querydsl and geodb seems to have lots of improvements in git master compared to the latest release.
The artifacts of version 0.4 are not available in the repo.opengeo.org maven repository. Can you make these available. It would be nice to use the latest features (issues 1 and 2).
I started writing an extension for Liquibase. GeoDB came in useful for H2 but I'd also like to support Derby. I forked the project and have a version that works for both H2 and Derby. If possible, I would like to contribute this back to the main project once it is ready. This is my first time doing such a thing so recommendations are welcome.
I'm using the 0.8 version and there is a problem with ST_EXTENT:
@OverRide
protected void add(Geometry geometry) {
if (result == null) {
result = geometry;
} else {
if (geometry != null) {
result = result.union(geometry.getEnvelope());
}
}
}
If result is null you set it to geometry. The next geometry gets its envelope added with union. Now, this will work if the geometries are polygon. But when the geometry is for example LineString, the first union will create a geometry collection (linestring from the first iteration and the polygon from GetEnvelope...) which can not be unified (JTS union actually has a check: checkNotGeometryCollection(this);)
The solution is to set the result to geometry.getEnvelope in the first iteration.
See related discussion on #23
The issue is the name clash in the name of the spatial index table... _HATBOX
create table spatial (id INT AUTO_INCREMENT PRIMARY KEY);
call AddGeometryColumn(NULL, 'SPATIAL', 'FOO', 4326, 'POINT', 2);
call AddGeometryColumn(NULL, 'SPATIAL', 'BAR', 4326, 'POLYGON', 2);
call CreateSpatialIndex(NULL, 'SPATIAL', 'FOO', 4326);
call CreateSpatialIndex(NULL, 'SPATIAL', 'BAR', 4326);
I just recently pulled down the some artifacts from the opengeo maven repository
(geodb-0.8.jar, geodb-0.8-sources.jar, and hatbox-1.0.b9.jar) and all 3 had mismatched sha-1 and md5 checksums. Just to make sure I wasn't crazy, I pulled down another jar from the same repo (hsqldb-1.8.0.7) and it's checksums were correct, so perhaps the problem only exists with these particular artifacts...
When doing a query, using ST_SRID(), the result is always 0. Since Hibernate Spatial uses this method in its test queries (see below an example query), the GeoDB dialect cannot be made compatible.
A possible solution would be to always store geometries as EWKB, but this probably break the current support for WKB/WKT methods.
Hibernate Spatial query (from test suite):
select geomentity0_.id as col_0_0_, ST_Within(geomentity0_.geom, ST_GeomFromText(?, 4326)) as col_1_0_ from GEOMTEST geomentity0_ where ST_Within(geomentity0_.geom, ST_GeomFromText(?, 4326))=1 and ST_SRID(geomentity0_.geom)=4326
For Moodcat (a study project) I use Geodb to test our spacial queries (Hibernate, QueryDSL) against H2 (production runs under Postgres). I currently experience a query that runs on Postgres, but fails in H2 / Geodb. I have no idea if this is due to a configuration mistake or a bug / unimplemented feature in Geodb.
It seems that ST_DISTANCE can not be found at the point where the statement is prepared.
Below I have attached the stacktraces, which also includes the prepared statement.
18:24:01.474 ERROR m.m.core.mappers.AbstractExceptionMapper - org.hibernate.exception.GenericJDBCException: could not prepare statement (cd6aae0a-1c15-456b-945b-7736f68573c7)
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at com.mysema.query.jpa.impl.AbstractJPAQuery.getResultList(AbstractJPAQuery.java:197) ~[querydsl-jpa-3.6.4.jar:na]
at com.mysema.query.jpa.impl.AbstractJPAQuery.list(AbstractJPAQuery.java:249) ~[querydsl-jpa-3.6.4.jar:na]
at me.moodcat.database.controllers.RoomDAO.queryRooms(RoomDAO.java:97) ~[classes/:na]
at me.moodcat.api.RoomAPI.getRooms(RoomAPI.java:71) ~[classes/:na]
at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:66) ~[guice-persist-3.0.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137) ~[resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296) ~[resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250) ~[resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237) ~[resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356) [resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179) [resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220) [resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56) [resteasy-jaxrs-3.0.11.Final.jar:na]
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51) [resteasy-jaxrs-3.0.11.Final.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) [javax.servlet-api-3.1.0.jar:3.1.0]
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:808) [jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66) [guice-servlet-3.0.jar:na]
at com.google.inject.persist.PersistFilter.doFilter(PersistFilter.java:89) [guice-persist-3.0.jar:na]
at com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118) [guice-servlet-3.0.jar:na]
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113) [guice-servlet-3.0.jar:na]
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [jetty-servlet-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.Server.handle(Server.java:497) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) [jetty-server-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) [jetty-io-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [jetty-util-9.2.10.v20150310.jar:9.2.10.v20150310]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:196) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:160) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1885) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doQuery(Loader.java:910) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2554) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.doList(Loader.java:2540) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.Loader.list(Loader.java:2365) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:387) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) ~[hibernate-entitymanager-4.3.8.Final.jar:4.3.8.Final]
... 44 common frames omitted
Caused by: org.h2.jdbc.JdbcSQLException: Function "ST_DISTANCE" not found; SQL statement:
select room0_.id as id1_2_, room0_.currentSong as currentS5_2_, room0_.name as name2_2_, room0_.repeat as repeat3_2_, room0_.location as location4_2_ from room room0_ order by ST_Distance(room0_.location, ?) asc limit ? [90022-187]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) ~[h2-1.4.187.jar:1.4.187]
at org.h2.message.DbException.get(DbException.java:179) ~[h2-1.4.187.jar:1.4.187]
at org.h2.message.DbException.get(DbException.java:155) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readJavaFunction(Parser.java:2351) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readFunction(Parser.java:2403) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readTerm(Parser.java:2737) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readFactor(Parser.java:2259) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readSum(Parser.java:2246) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readConcat(Parser.java:2216) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readCondition(Parser.java:2066) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readAnd(Parser.java:2038) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.readExpression(Parser.java:2030) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parseEndOfQuery(Parser.java:1741) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parseSelectUnionExtension(Parser.java:1721) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parseSelectUnion(Parser.java:1690) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parseSelect(Parser.java:1677) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parsePrepared(Parser.java:433) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parse(Parser.java:305) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.parse(Parser.java:277) ~[h2-1.4.187.jar:1.4.187]
at org.h2.command.Parser.prepareCommand(Parser.java:242) ~[h2-1.4.187.jar:1.4.187]
at org.h2.engine.Session.prepareLocal(Session.java:461) ~[h2-1.4.187.jar:1.4.187]
at org.h2.engine.Session.prepareCommand(Session.java:403) ~[h2-1.4.187.jar:1.4.187]
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1189) ~[h2-1.4.187.jar:1.4.187]
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:72) ~[h2-1.4.187.jar:1.4.187]
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:277) ~[h2-1.4.187.jar:1.4.187]
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:162) ~[c3p0-0.9.2.1.jar:0.9.2.1]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:162) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:186) ~[hibernate-core-4.3.8.Final.jar:4.3.8.Final]
... 61 common frames omitted
Thanks for your effort on this project!
When running geodb-0.8 with an embedded H2 version 1.4.185, dropping an indexed spatial table produces an error :
org.h2.jdbc.JdbcSQLException: General error: "java.lang.AbstractMethodError: net.sourceforge.hatbox.jts.InsertTrigger.remove()V"; SQL statement:
DROP TABLE "carto"."test" CASCADE [50000-185]
What is the minimum/maximum H2 version supported by geodb ? Any plan to upgrade ?
As well make it possible to pass various options to the h2 server
We've come across a peculiar error in GeoDB's (E)WKB methods. Converting a geometry to an EWB (byte[]) and then converting this back to a geometry leads to a geometry that is not the same as its original.
The JUnit test below shows this behaviour (using version 0.6 of GeoDB from the Maven repository). A Point with coordinates (10, 10) is written to an EWKB and then transformed back to a Geometry. The result is a Poin with coordinates (0,0). Probably the error occurs on line 1173 of the GeoDB class).
package geodb;
import junit.framework.Assert;
import geodb.GeoDB;
import org.hibernatespatial.test.EWKTReader;
import org.junit.Test;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.ParseException;
public class GeoDBEWKBTest {
@Test
public void testGToEWKB() throws ParseException {
Geometry g = new EWKTReader().read("SRID=4326;POINT (10 10)");
// to and from ewkb
byte[] ewkb = GeoDB.gToEWKB(g);
Geometry gFromEwkb = GeoDB.gFromEWKB(ewkb);
Assert.assertEquals(g, gFromEwkb);
}
}
Hi, I am trying to use the geodb as a dependency and I am seeing
Downloading from central: https://repo.maven.apache.org/maven2/org/opengeo/geodb/0.9/geodb-0.9.pom
[WARNING] The POM for org.opengeo:geodb:jar:0.9 is missing, no dependency information available
and my build fails because of this. Comparing with one of my own projects to geodb there seems to be some files missing?
I'd like to use GeoDB for unit tests in a Maven project, but as far as I can tell there are no GeoDB-related artifacts in Maven Central: http://search.maven.org/#search|ga|1|geodb
This seems odd, as I've seen sample code that refers to GeoDB artifacts. Were they removed for some reason?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.