diff --git a/README.rst b/README.rst index 43b81f0..6b572cd 100644 --- a/README.rst +++ b/README.rst @@ -11,6 +11,9 @@ Dependencies You will need ckan installed, as well as the ckanext-dgu and ckanext-csw plugins activated. +If you want to use the spatial search API, you will need PostGIS installed +and enable the spatial features of your PostgreSQL database. See the +"Setting up PostGIS" section for details. Configuration ============= @@ -98,4 +101,98 @@ forms: - 4258 +Setting up PostGIS +================= +Configuration +------------- + +* Install PostGIS:: + + sudo apt-get install postgresql-8.4-postgis + +* Create a new PostgreSQL database:: + + sudo -u postgres createdb [database] + + (If you just want to spatially enable an exisiting database, you can + ignore this point, but it's a good idea to create a template to + make easier to create new databases) + +* Many of the PostGIS functions are written in the PL/pgSQL language, + so we need to enable it in our database:: + + sudo -u postgres createlang plpgsql [database] + +* Run the following commands. The first one will create the necessary + tables and functions in the database, and the second will populate + the spatial reference table:: + + sudo -u postgres psql -d [database] -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql + sudo -u postgres psql -d [database] -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql + +* Execute the following command to see if PostGIS was properly + installed:: + + sudo -u postgres psql -d [database] -c "SELECT postgis_full_version()" + + You should get something like:: + + postgis_full_version +------------------------------------------------------------------------------------------------------- + POSTGIS="1.5.2" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.7" USE_STATS +(1 row) + + Also, if you log into the database, you should see two tables, + ``geometry_columns`` and ``spatial_ref_sys`` (and probably a view + called ``geography_columns``). + + Note: This commands will create the two tables owned by the postgres + user. You probably should make owner the user that will access the + database from ckan:: + + ALTER TABLE spatial_ref_sys OWNER TO [your_user]; + ALTER TABLE geometry_columns OWNER TO [your_user]; + +More information on PostGIS installation can be found here: + +http://postgis.refractions.net/docs/ch02.html#PGInstall + + + +Setting up a spatial table +-------------------------- + +To be able to store geometries and perform spatial operations, PostGIS +needs to work with geometry fields. Geometry fields should always be +added via the ``AddGeometryColumn`` function:: + + CREATE TABLE package_extent( + package_id text PRIMARY KEY + ); + + ALTER TABLE package_extent OWNER TO [your_user]; + + SELECT AddGeometryColumn('package_extent','the_geom', 4258, 'POLYGON', 2); + +This will add a geometry column in the ``package_extent`` table called +``the_geom``, with the spatial reference system EPSG:4258. The stored +geometries will be polygons, with 2 dimensions. + +Have a look a the table definition, and see how PostGIS has created +three constraints to ensure that the geometries follow the parameters +defined in the geometry column creation:: + +# \d package_extent + + Table "public.package_extent" + Column | Type | Modifiers +------------+----------+----------- + package_id | text | not null + the_geom | geometry | +Indexes: + "package_extent_pkey" PRIMARY KEY, btree (package_id) +Check constraints: + "enforce_dims_the_geom" CHECK (st_ndims(the_geom) = 2) + "enforce_geotype_the_geom" CHECK (geometrytype(the_geom) = 'POLYGON'::text OR the_geom IS NULL) + "enforce_srid_the_geom" CHECK (st_srid(the_geom) = 4258) diff --git a/public/ckanext/harvest/js/openlayers/OpenLayers_ckan.js b/public/ckanext/harvest/js/openlayers/OpenLayers_ckan.js index 6fb9716..d7902f9 100644 --- a/public/ckanext/harvest/js/openlayers/OpenLayers_ckan.js +++ b/public/ckanext/harvest/js/openlayers/OpenLayers_ckan.js @@ -122,7 +122,15 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - */var OpenLayers={VERSION_NUMBER:"$Revision: 10995 $",singleFile:true,_getScriptLocation:(function(){var r=new RegExp("(^|(.*?\\/))(OpenLayers\.js)(\\?|$)"),s=document.getElementsByTagName('script'),src,m,l="";for(var i=0,len=s.length;i";} @@ -823,4 +831,4 @@ this.map.events.register('moveend',this,this.updateScale);this.updateScale();ret var inches=OpenLayers.INCHES_PER_UNIT;scale=(this.map.getGeodesicPixelSize().w||0.000001)*inches["km"]*OpenLayers.DOTS_PER_INCH;}else{scale=this.map.getScale();} if(!scale){return;} if(scale>=9500&&scale<=950000){scale=Math.round(scale/1000)+"K";}else if(scale>=950000){scale=Math.round(scale/1000000)+"M";}else{scale=Math.round(scale);} -this.element.innerHTML=OpenLayers.i18n("scale",{'scaleDenom':scale});},CLASS_NAME:"OpenLayers.Control.Scale"}); \ No newline at end of file +this.element.innerHTML=OpenLayers.i18n("scale",{'scaleDenom':scale});},CLASS_NAME:"OpenLayers.Control.Scale"}); diff --git a/public/ckanext/harvest/js/openlayers/README.txt b/public/ckanext/harvest/js/openlayers/README.txt index 6e36bfe..ce29d61 100644 --- a/public/ckanext/harvest/js/openlayers/README.txt +++ b/public/ckanext/harvest/js/openlayers/README.txt @@ -14,3 +14,7 @@ distribution: python build.py {path-to-ckan.cfg} {output-file} +The theme used for the OpenLayers controls is the "dark" theme made available +by Development Seed under the BSD License: + +https://github.com/developmentseed/openlayers_themes/blob/master/LICENSE.txt