@@ -0,0 +1,1335 @@
+package com.github.davidmoten.h2gis;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.DriverManager;%0Aimport java.sql.ResultSet;%0Aimport java.sql.Statement;%0A%0Aimport org.h2gis.h2spatialext.CreateSpatialExtension;%0Aimport org.junit.Test;%0A%0A/**%0A * Short demo of in memory spatial database.%0A */%0Apublic class H2gisTest %7B%0A%0A%09@Test%0A%09public void test() throws Exception %7B%0A%09%09Class.forName(%22org.h2.Driver%22);%0A%09%09// Open memory H2 table%0A%09%09try (Connection connection = DriverManager.getConnection(%0A%09%09%09%09%22jdbc:h2:mem:syntax%22, %22sa%22, %22sa%22);%0A%09%09%09%09Statement st = connection.createStatement()) %7B%0A%09%09%09// Import spatial functions, domains and drivers%0A%09%09%09// If you are using a file database, you have to do only that%0A%09%09%09// once.%0A%09%09%09CreateSpatialExtension.initSpatialExtension(connection);%0A%09%09%09// Create a table%0A%09%09%09st.execute(%22CREATE TABLE ROADS (the_geom MULTILINESTRING, speed_limit INT)%22);%0A%09%09%09// Add some roads%0A%09%09%09st.execute(%22INSERT INTO ROADS VALUES ('MULTILINESTRING((15 5, 20 6, 25 7))', 80)%22);%0A%09%09%09st.execute(%22INSERT INTO ROADS VALUES ('MULTILINESTRING((20 6, 21 15, 21 25))', 50)%22);%0A%09%09%09// Compute the sum of roads length%0A%09%09%09try (ResultSet rs = st%0A%09%09%09%09%09.executeQuery(%22SELECT SUM(ST_LENGTH(the_geom)) total_length from ROADS%22)) %7B%0A%09%09%09%09if (rs.next()) %7B%0A%09%09%09%09%09System.out.println(%22Total length of roads: %22%0A%09%09%09%09%09%09%09+ rs.getDouble(%22total_length%22) + %22 m%22);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%7D

add test for h2gis