You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by ma...@apache.org on 2010/11/09 07:21:34 UTC

svn commit: r1032860 - in /incubator/sis/trunk: CHANGES.txt README.txt sis-webapp/src/main/java/org/apache/sis/services/LocationServlet.java sis-webapp/src/main/webapp/META-INF/context.xml

Author: mattmann
Date: Tue Nov  9 06:21:34 2010
New Revision: 1032860

URL: http://svn.apache.org/viewvc?rev=1032860&view=rev
Log:
- fix for SIS-20 Make the qTreeIdxPath and geodata paths configurable properties

Modified:
    incubator/sis/trunk/CHANGES.txt
    incubator/sis/trunk/README.txt
    incubator/sis/trunk/sis-webapp/src/main/java/org/apache/sis/services/LocationServlet.java
    incubator/sis/trunk/sis-webapp/src/main/webapp/META-INF/context.xml

Modified: incubator/sis/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/CHANGES.txt?rev=1032860&r1=1032859&r2=1032860&view=diff
==============================================================================
--- incubator/sis/trunk/CHANGES.txt (original)
+++ incubator/sis/trunk/CHANGES.txt Tue Nov  9 06:21:34 2010
@@ -2,6 +2,9 @@ Apache SIS Change Log
 ======================
 Release 0.1-incubating (Current Development)
 
+* SIS-20 Make the qTreeIdxPath and geodata paths configurable 
+  properties (mattmann)
+
 * SIS-19 QTreeWriter and GeoRSSData.save don't check to make sure 
   the directory exists before creating data there (mattmann)
 

Modified: incubator/sis/trunk/README.txt
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/README.txt?rev=1032860&r1=1032859&r2=1032860&view=diff
==============================================================================
--- incubator/sis/trunk/README.txt (original)
+++ incubator/sis/trunk/README.txt Tue Nov  9 06:21:34 2010
@@ -28,7 +28,9 @@ file (WAR) you can use to try out SISfea
     cp -R /path/to/apache-sis-X.Y-src/sis-webapp/target/sis-webapp-X.Y.war ./
     cp -R /path/to/apache-sis-X.Y-src/sis-webapp/src/main/webapp/META-INF/context.xml ./sis.xml
     edit sis.xml (set the docBase to /usr/local/sis/sis-webapp-X.Y.war and the property 
-          org.apache.sis.services.config.filePath to /usr/local/sis/sis-location-config.xml)
+          org.apache.sis.services.config.filePath to /usr/local/sis/sis-location-config.xml, 
+          org.apache.sis.services.config.qIndexPath to /usr/local/sis/qtree, 
+          org.apache.sis.services.config.geodataPath to /usr/local/sis/geodata)
     cp -R /path/to/apache-sis-X.Y-src/sis-webapp/src/main/resources/sis-location-config.xml ./
     edit sis-location-config.xml (add or delete GeoRSS URLs)
     ln -s /usr/local/sis/sis.xml /usr/local/tomcat/conf/Catalina/localhost/sis.xml

Modified: incubator/sis/trunk/sis-webapp/src/main/java/org/apache/sis/services/LocationServlet.java
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-webapp/src/main/java/org/apache/sis/services/LocationServlet.java?rev=1032860&r1=1032859&r2=1032860&view=diff
==============================================================================
--- incubator/sis/trunk/sis-webapp/src/main/java/org/apache/sis/services/LocationServlet.java (original)
+++ incubator/sis/trunk/sis-webapp/src/main/java/org/apache/sis/services/LocationServlet.java Tue Nov  9 06:21:34 2010
@@ -21,6 +21,7 @@ package org.apache.sis.services;
 import java.awt.geom.Rectangle2D;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
@@ -89,13 +90,22 @@ public class LocationServlet extends Htt
     long startTime = 0;
     long endTime = 0;
     int capacity=-1, depth=-1;
-    InputStream indexStream = config.getServletContext().getResourceAsStream(
-        File.separator + "index" + File.separator + "node_0.txt");
+    String qtreeIdxPath = this.context.getInitParameter("org.apache.sis.services.config.qIndexPath");
+    String georssStoragePath = this.context.getInitParameter("org.apache.sis.services.config.geodataPath");
+    
+    if(!qtreeIdxPath.endsWith("/")) qtreeIdxPath+="/";
+    if(!georssStoragePath.endsWith("/")) georssStoragePath+="/";
+    
+    InputStream indexStream = null;
+    try {
+      indexStream = new FileInputStream(qtreeIdxPath+"node_0.txt");
+    } catch (FileNotFoundException e) {
+      e.printStackTrace();      
+    }
+    
     if (indexStream != null) {
       startTime = System.currentTimeMillis();
-      this.tree = QuadTreeReader.readFromFile(config.getServletContext()
-          .getRealPath("/")
-          + "index" + File.separator, "tree_config.txt", "node_0.txt");
+      this.tree = QuadTreeReader.readFromFile(qtreeIdxPath, "tree_config.txt", "node_0.txt");
       try {
         indexStream.close();
       } catch (IOException e) {
@@ -167,9 +177,7 @@ public class LocationServlet extends Htt
                         .getPosition().getLongitude()));
                 if (this.tree.insert(data)) {
                   data.saveToFile(item, geoRSSModule,
-
-                  config.getServletContext().getRealPath("/") + "geodata"
-                      + File.separator);
+                      georssStoragePath);
                 } else {
                   System.out.println("[INFO] Unable to store data at location "
                       + data.getLatLon().getLat() + ", " + data.getLatLon().getLon()
@@ -182,9 +190,7 @@ public class LocationServlet extends Htt
           endTime = System.currentTimeMillis();
           this.timeToLoad = "Quad Tree fully loaded from retrieving GeoRSS files over the network in "
               + Double.toString((endTime - startTime) / 1000L) + " seconds";
-          QuadTreeWriter.writeTreeToFile(tree, config.getServletContext()
-              .getRealPath("/")
-              + "index" + File.separator);
+          QuadTreeWriter.writeTreeToFile(tree, qtreeIdxPath);
         } catch (ParserConfigurationException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();

Modified: incubator/sis/trunk/sis-webapp/src/main/webapp/META-INF/context.xml
URL: http://svn.apache.org/viewvc/incubator/sis/trunk/sis-webapp/src/main/webapp/META-INF/context.xml?rev=1032860&r1=1032859&r2=1032860&view=diff
==============================================================================
--- incubator/sis/trunk/sis-webapp/src/main/webapp/META-INF/context.xml (original)
+++ incubator/sis/trunk/sis-webapp/src/main/webapp/META-INF/context.xml Tue Nov  9 06:21:34 2010
@@ -19,5 +19,11 @@ the License.
         
     <Parameter name="org.apache.sis.services.config.filePath" 
         value="/path/to/sis-location-config.xml" override="false"/>
+        
+    <Parameter name="org.apache.sis.services.config.qIndexPath"
+        value="/path/to/qtree/index/dir" override="false"/>
+        
+    <Parameter name="org.apache.sis.services.config.geodataPath"
+        value="/path/to/georss/xml/files/dir" override="false"/>
 
 </Context>