[squeak-dev] Glorp-PostGIS

Zulq Alam me at zulq.net
Sat Feb 14 13:31:50 UTC 2009


Hi All,

I've created a project on Squeaksource for an extension to Glorp to 
integrate with PostGIS. So far it works for simple point geometries. The 
repository is globally writeable and I'm interested in your feedback.

To run the unit tests you will need a Postgres database with PostGIS 
installed. Modify PGTestResource>>setUpLogin with the database details.

Note that the application can work in a different coordinate system than 
the database type. Conversion will be done automatically. Here is an 
example of usage.

TubeDescriptorSystem>>tableForTUBESTATION: aTable
   (aTable createFieldNamed: 'id' type: platform sequence) bePrimaryKey.
   aTable createFieldNamed: 'longitude' type: platform float.
   aTable createFieldNamed: 'latitude' type: platform float.
   aTable
     createFieldNamed: 'point'
     type: (platform point: 32661 dimensions: 2)

TubeStation>>longitude: aLongitude latitude: aLatitude
   longitude := longitude
   latitude := latitude
   point := PGPoint x: longitude y: latitude srid: 4326.

" FYI, Highbury is closest to Angel "
holloway := TubeStation longitude: -0.11278 latitude: 51.5529.
highbury := TubeStation longitude: -0.10752 latitude: 51.54502.
angel := TubeStation longitude: -0.10579 latitude: 51.53253.

session inUnitOfWorkDo: [
   session register: highbury.
   session register: holloway.
   session register: angel.
].

" This returns highbury "
session
   readOneOf: TubeStation
   where:
     [:e | (e point distanceTo: angel point) between: 1000 and: 2000]

" This returns angel and highbury "
session
   readManyOf: TubeStation
   where:
     [:e | e point distanceTo: angel point within: 2000].

" This returns angel, highbury then holloway "
session
   readManyOf: TubeStation
   orderBy: [:e | e point distanceTo: angel point].

One thing to watch out for is you shouldn't use PGPoint objects directly 
- or should be careful. Although they are converted to the correct SRID 
when saved, the instance variable is not updated until the object is 
refreshed.

Thanks,
Zulq.





More information about the Squeak-dev mailing list