Skip to content

Commit 8377b7b

Browse files
committed
Use PostGIS 1.5 and WKT and make compatible
1 parent 5e4ce77 commit 8377b7b

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

.travis.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ node_js:
44
env:
55
- NODE_ENV="development"
66
before_install:
7-
- echo "yes" | sudo apt-add-repository ppa:0k53d-karl-f830m/postgis
8-
- sudo apt-get update
97
- sudo apt-get install -qq postgis
108
before_script:
11-
- psql -c "CREATE DATABASE test;" -U postgres
9+
- psql -c "CREATE DATABASE test TEMPLATE template_postgis;" -U postgres
1210
- psql -f ./test/sql/init.sql -U postgres -d test
1311
- ./bin/postgresql-http-server --user postgres --database test &

lib/db.coffee

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ module.exports = (log, connectionString, database) ->
6666
count = 1
6767
for k,v of row
6868
fields.push "\"#{k}\""
69-
params.push if k is 'geom' then "ST_GeomFromGeoJSON($#{count})" else "$#{count}"
69+
params.push "$#{count}"
70+
# TODO: use something like the below to accept GeoJSON instead of WKT
71+
#params.push if k is 'geom' then "ST_GeomFromGeoJSON($#{count})" else "$#{count}"
7072
values.push v
7173
count += 1
7274

test/specs/resources/rows.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe 'Rows resource', ->
5353
'Content-Type': 'application/json'
5454
body:
5555
name: 'updatedfirst',
56-
geom: '{"type":"Point","coordinates":[-48.23456,20.12345]}'
56+
geom: 'POINT (-48.23456 20.12345)'
5757
callback: (res, data) ->
5858
assert res.statusCode is 200, "#{res.statusCode} should be 200"
5959
done()

test/sql/init.sql

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION postgis;
22
DROP SCHEMA IF EXISTS testschema CASCADE;
33
CREATE SCHEMA testschema;
4-
CREATE TABLE testschema.testtable (id SERIAL PRIMARY KEY, name varchar, geom GEOMETRY(Point));
4+
CREATE TABLE testschema.testtable (id SERIAL PRIMARY KEY, name varchar);
5+
SELECT AddGeometryColumn('testschema', 'testtable', 'geom', 0, 'POINT', 2);

0 commit comments

Comments
 (0)