Hi all, I am working on the drawing part of my shape-file reading package, and wondered what would be the fastest way to get all these polygons on the screen. Being geographically referenced, the vertices need to be scaled and transformed. I did this by first creating a Form of the desired extent, than defining a BalloonCanvas on this Form, and calculating a scaling factor.
form _ Form extent: aPoint depth: anInteger. polyColor _ self polygonColor. arcColor _ self arcColor. form fillColor: self backgroundColor. canvas _ BalloonCanvas on: form. canvas aaLevel: 4. geoBB _ self boundingBox. scaling _ form extent x / geoBB extent x min: form extent y / geoBB extent y.
Next with this scaling factor I create a MatrixTransform2x3, attach this to the canvas, and iterate over all polygons, using the #drawGeneralPolygon:color:borderWidth:borderColor: method to do the display.
m _ MatrixTransform2x3 withScale: 1 @ -1 * scaling. m offset: self xMin negated @ self yMax * scaling. canvas transformBy: m. 1 to: self numberOfShapes do: [:i | | contours | contours _ self verticesByPartsForShapeIndex: i. canvas drawGeneralPolygon: contours color: "polyColor" Color random borderWidth: 1 borderColor: arcColor]
Is this the approach with the best possible performance, given that scaling and transformation will always be necessary? Would it be advisable to cache scaled and transformed polygons, or is scaling and transformation within the #drawGeneralPolygon:color:borderWidth:borderColor: method not too costly? I would like to reach the same display speed for a shape file as the ESRI ArcView GIS (though they may use all kinds of smart optimizations there ...) ;-)
Comments and advise are really appreciated!
Hans
Am 01.10.2004 um 15:28 schrieb Baveco, Hans:
Hi all, I am working on the drawing part of my shape-file reading package, and wondered what would be the fastest way to get all these polygons on the screen.
You might want to look at how the flash rendering is implemented, which is pretty efficient.
- Bert -
squeak-dev@lists.squeakfoundation.org