Thanks Hernan!
I will try to find out what the problem is with your shape file.
Btw is the code for reading/writing dbf files already available on github?
Hans
From: Hern��n Morales Durand <hernan.morales@gmail.com>
Sent: vrijdag 5 juni 2020 0:25
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
Subject: Re: [Pharo-users] GIS support for Pharo
Hi Hans,
El jue., 4 jun. 2020 a las 6:07, Baveco, Hans (<hans.baveco@wur.nl>) escribi��:
Would be an interesting project..
An old link to possibly still useful code:
http://wiki.squeak.org/squeak/3317
Btw the shapefile support, from the ESRI spec, was done by me and is still available on http://www.squeaksource.com/@CUT95k_uXmPU4uXY/HCmgtrop.
Thank you for the clarification (and actually sharing your work with ESRI files!)
I added proper credits in the Github forked repo :
https://github.com/hernanmd/Shapes
I use it daily. I may have some fixes/additions, but in general the code as provided works well (I suppose the code at smalltalkhub is still mostly the same). Some shapefile formats are still missing, mostly because I never encountered them..
You mean some types are missing? Because I get this error when I try to read some SHP files: "Types > 20 are not yet accounted for"
I wrote this script to reproduce:
| shpE legend urlRoot urlESRIFilePrefix urlESRIFileShp urlPath response fileRef |
" Download Shapefile resources "
urlRoot := 'https://github.com/nvkelso/natural-earth-vector/blob/master/110m_cultural/'.
urlESRIFilePrefix := 'ne_110m_populated_places'.
urlESRIFileShp := urlESRIFilePrefix , '.shp'.
urlPath := urlRoot , urlESRIFilePrefix.
#('.shx' '.dbf' '.shp') do: [ : ext |
| url |
url := (urlPath , ext , '?raw=true') asZnUrl.
(response := ZnEasy get: url) isSuccess
ifFalse: [ self error: 'Cannot download file' ].
fileRef := FileSystem disk workingDirectory / (urlESRIFilePrefix , ext).
fileRef writeStreamDo: [ : stream |
stream nextPutAll: ((ZnByteEncoder newForEncoding: 'koi8r') decodeBytes: response contents ) ] ].
Once downloaded:
| urlESRIFilePrefix urlESRIFileShp shpE |
urlESRIFilePrefix := 'ne_110m_populated_places'.
urlESRIFileShp := urlESRIFilePrefix , '.shp'.
" Load and display it in Morphic "
shpE := ShapeEnsemble fromFile: urlESRIFileShp.
Maybe it's related with the fact they are encoded as koi8r?
I checked with Zinc downloading first from the browser:
| shpFile |
shpFile := 'ne_110m_admin_0_countries.shp' asFileReference.
[ shpFile binaryReadStreamDo: [ : in |
(ZnCharacterEncoder detectEncoding: in upToEnd) identifier ] ]
on: ZnCharacterEncodingError
do: [ nil ].
Cheers,
Hern��n
To read a complete shapefile one also needs to read dbf files. This was another substantial effort http://www.squeaksource.com/@Y4HhnL90iyA2TmAb/X0sPqshM; luckily there was an older implementation.available to build upon.
Not sure whether nowadays there are other ways to read/write files old DBASE format files...
Cheers,
Hans Baveco
From: Serge Stinckwich <serge.stinckwich@gmail.com>
Sent: donderdag 4 juni 2020 5:32
To: Any question about pharo is welcome <pharo-users@lists.pharo.org>
Subject: [Pharo-users] GIS support for Pharo
Dear all,
there was already some discussion in the list about GIS support for Pharo previously.
Working on CORMAS multi-agent simulation platform: https://github.com/cormas/cormas some developers feel the need to have more GIS support for Pharo.
I know of existing GIS software:
- GeoJSON by Zweidenker: https://github.com/zweidenker/GeoJSON
- ESRI ascii raster, done by Stephane recently: https://github.com/Ducasse/ESRI-ASCII-Raster
- shapefile support by Hernan: http://smalltalkhub.com/#!/~hernan/Shapes
(to be moved to github)
- I found this project also: http://www.squeaksource.com/gekon.html
I know that Etienne Delay is also interested by GIS support and propose to implement OpenGIS model support: https://github.com/cormas/cormas/issues/139
Can we try to unite and maybe create a pharo-GIS organization on github to federate our efforts?
Cheers,
--