Just a test and a note to self.
wget http://www2.census.gov/geo/tiger/GENZ2015/kml/cb_2015_us_county_500k.zip
unzip cb_2015_us_county_500k.zip
sudo su - postgres -c "createuser states -PE"
sudo su - postgres -c "createdb -O states states"
sudo su - postgres -c "echo CREATE extension IF NOT EXISTS postgis|psql states"
Password kissa
expected from now on
PG_USE_COPY=YES PGPASSWORD=kissa ogr2ogr \
-f "PostgreSQL" \
PG:"host=localhost user=states dbname=states" \
-a_srs "EPSG:3395" \
-append \
-nlt MULTIPOLYGON \
-nln counties cb_2015_us_county_500k.kml
wget -Ogeoserver-2.10.1-bin.zip "https://downloads.sourceforge.net/project/geoserver/GeoServer/2.10.1/geoserver-2.10.1-bin.zip?r=http%3A%2F%2Fgeoserver.org%2Frelease%2Fstable%2F&ts=1485280136&use_mirror=freefr"
unzip geoserver-2.10.1-bin.zip
GEOSERVER_HOME="$(pwd)/geoserver-2.10.1" geoserver-2.10.1/bin/startup.sh
# Create workspace
curl -v -X POST \
-H "Content-Type: text/xml" \
-u admin:geoserver \
-d "<workspace><name>counties</name></workspace>" \
http://localhost:8080/geoserver/rest/workspaces
# Add data store
curl -v -X POST \
-H "Content-Type: text/xml" \
-u admin:geoserver \
-d "<dataStore><name>states</name><connectionParameters><host>localhost</host><port>5432</port><database>states</database><user>states</user><passwd>kissa</passwd><dbtype>postgis</dbtype></connectionParameters></dataStore>" \
http://localhost:8080/geoserver/rest/workspaces/counties/datastores
# Add table from the store as feature type
curl -v -X POST \
-H "Content-Type: text/xml" \
-u admin:geoserver \
-d "<featureType><name>counties</name></featureType>" \
http://localhost:8080/geoserver/rest/workspaces/counties/datastores/states/featuretypes
- Go to
http://localhost:8080/geoserver
- Login with:
admin
/geoserver
- Select
Layer Preview
- You should see layer
counties
. From that row, clickOpenLayers
link