Displaying differences for changeset
 
display as  

src/java/m/gis/Database.java

@@ -20,7 +20,6 @@
 public abstract class Database {
 
     public static enum DataType {NUMERIC, STRING};
-    public static final String SCHEMA = "csip_gis";
     public final String SESSION_ID;
 
     protected Connection conn;

src/java/m/gis/GeoJSONParser.java

@@ -20,7 +20,6 @@
 public class GeoJSONParser implements Parser {
 
     enum ShapeType {Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, GeometryCollection};
-    public static String DEFAULT_CRS = "EPSG:4326"; // EPSG 4326
     protected final Logger LOG = Logger.getLogger(getClass().getSimpleName());
 
     JSONArray layersJSON;
@@ -74,7 +73,7 @@
 
     public Feature parseFeature(JSONObject featureJSON, JSONObject layerJSON, Layer lyr) throws ServiceException {
         try {
-            JSONObject crs = generateCRS(DEFAULT_CRS);
+            JSONObject crs = generateCRS(Constants.DEFAULT_CRS);
             if (hasCRS(featureJSON)) {
                 crs = featureJSON.getJSONObject("crs");
             } else if (hasCRS(layerJSON)) {

src/java/m/gis/PostgresqlDatabase.java

@@ -35,7 +35,7 @@
 
     public PostgresqlDatabase(String hostname, String port, String dbName, String username, String password) throws ServiceException {
         super(hostname, port, dbName, username, password);
-        createSchema(SCHEMA);
+        createSchema(Constants.DEFAULT_SCHEMA);
     }
 
     @Override
@@ -56,20 +56,20 @@
         Layer lyr = null;
         try {
             GeoJSONParser.ShapeType shapeType = GeoJSONParser.getShape(layerJSON);
-            String schemaTable = SCHEMA + ".\"" + tableName + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + tableName + "\"";
             Statement stmt = conn.createStatement();
-            if (!exists(SCHEMA, tableName)) {
+            if (!exists(Constants.DEFAULT_SCHEMA, tableName)) {
                 String sql = "CREATE TABLE " + schemaTable + " (id serial)";
                 LOG.log(Level.INFO, sql);
                 stmt.executeUpdate(sql);
 
                 sql = "SELECT AddGeometryColumn ('" + 
-                        SCHEMA + "','" + tableName + "', 'the_geom', " + 
+                        Constants.DEFAULT_SCHEMA + "','" + tableName + "', 'the_geom', " + 
                         "4326, '" + shapeType + "', 2);";
                 LOG.log(Level.INFO, sql);
                 stmt.executeQuery(sql);
             }
-            lyr = new Layer(SCHEMA, tableName, this);
+            lyr = new Layer(Constants.DEFAULT_SCHEMA, tableName, this);
 
             stmt.close();
         } catch (JSONException|SQLException ex) {
@@ -102,7 +102,7 @@
 
             // Create column fields for all properties.
             if (!featureJSON.isNull("properties")) {
-                ArrayList<String> columnNames = getColumns(SCHEMA, layer.table);
+                ArrayList<String> columnNames = getColumns(Constants.DEFAULT_SCHEMA, layer.table);
                 JSONObject props = featureJSON.getJSONObject("properties");
                 Iterator<?> keys = props.keys();
                 while (keys.hasNext()) {
@@ -112,12 +112,12 @@
                     vals.add(props.get(key));
                     if (!columnNames.contains(key)) {
                         if (props.get(key) instanceof String) {
-                            addColumn(SCHEMA, layer.table, key, DataType.STRING);
+                            addColumn(Constants.DEFAULT_SCHEMA, layer.table, key, DataType.STRING);
                         }
                         else if (props.get(key) instanceof Double || 
                                  props.get(key) instanceof Integer ||
                                  props.get(key) instanceof Number) {
-                            addColumn(SCHEMA, layer.table, key, DataType.NUMERIC);
+                            addColumn(Constants.DEFAULT_SCHEMA, layer.table, key, DataType.NUMERIC);
                         }
                     }
                 }
@@ -168,10 +168,10 @@
     public Layer intersect(Layer one, Layer two) throws ServiceException {
         try {
             String table = "intsn_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
 
-        deleteTable(schemaTable);
+            deleteTable(schemaTable);
 
             ArrayList<String> props = new ArrayList<>(Arrays.asList(new String[]{
                 "ST_Intersection(" + one.getSchemaTable() + ".the_geom, " + two.getSchemaTable() + ".the_geom) AS the_geom ",
@@ -186,7 +186,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -196,9 +196,9 @@
     public Layer union(Layer one, Layer two) throws ServiceException {
         try {
             String table = "union_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
-            createSchema(SCHEMA);
+            createSchema(Constants.DEFAULT_SCHEMA);
             deleteTable(schemaTable);
 
             ArrayList<String> props = new ArrayList<>(Arrays.asList(new String[]{
@@ -213,7 +213,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -223,9 +223,9 @@
     public Layer buffer(Layer lyr, int distance) throws ServiceException {
         try {
             String table = "buf_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
-            createSchema(SCHEMA);
+            createSchema(Constants.DEFAULT_SCHEMA);
             deleteTable(schemaTable);
 
             ArrayList<String> props = new ArrayList<>(Arrays.asList(new String[]{
@@ -239,7 +239,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -249,9 +249,9 @@
     public Layer minimumBoundingCircle(Layer lyr, int numSegsPerQtCirc) throws ServiceException {
         try {
             String table = "mbc_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
-            createSchema(SCHEMA);
+            createSchema(Constants.DEFAULT_SCHEMA);
             deleteTable(schemaTable);
 
             ArrayList<String> props = new ArrayList<>(Arrays.asList(new String[]{
@@ -266,7 +266,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -276,7 +276,7 @@
     public Layer minimumBoundingRectangle(Layer lyr) throws ServiceException {
         try {
             String table = "mbr_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
 
             JTSAdapter adapter = new JTSAdapter(this);
@@ -294,7 +294,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -304,9 +304,9 @@
     public Layer extent(Layer lyr) throws ServiceException {
         try {
             String table = "ext_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
-            createSchema(SCHEMA);
+            createSchema(Constants.DEFAULT_SCHEMA);
             deleteTable(schemaTable);
 
             ArrayList<String> props = new ArrayList<>(Arrays.asList(new String[]{
@@ -320,7 +320,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -330,9 +330,9 @@
     public Layer envelope(Layer lyr) throws ServiceException {
         try {
             String table = "env_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
-            createSchema(SCHEMA);
+            createSchema(Constants.DEFAULT_SCHEMA);
             deleteTable(schemaTable);
 
             ArrayList<String> props = new ArrayList<>(Arrays.asList(new String[]{
@@ -346,7 +346,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }
@@ -356,9 +356,9 @@
     public Layer area(Layer lyr) throws ServiceException {
         try {
             String table = "area_" + SESSION_ID + "_" + new RandomString(4).nextString();
-            String schemaTable = SCHEMA + ".\"" + table + "\"";
+            String schemaTable = Constants.DEFAULT_SCHEMA + ".\"" + table + "\"";
             Statement stmt = conn.createStatement();
-            createSchema(SCHEMA);
+            createSchema(Constants.DEFAULT_SCHEMA);
             deleteTable(schemaTable);
 
             ArrayList<String> colsExclude = new ArrayList<>(Arrays.asList(new String[]{"the_geom","id","calc_area"}));
@@ -374,7 +374,7 @@
             stmt.executeUpdate(sql);
 
             stmt.close();
-            return new Layer(SCHEMA, table, this);
+            return new Layer(Constants.DEFAULT_SCHEMA, table, this);
         } catch (SQLException ex) {
             throw new csip.ServiceException(ex);
         }