Re: [ZMapServer-Developers] ReferenceMap
Status: Alpha
Brought to you by:
sgillies
|
From: Sean G. <sgi...@fr...> - 2005-04-14 15:43:05
|
On Apr 13, 2005, at 8:41 AM, Florian Edelmaier wrote: > Hi list! > > Because we need a reference-map for our application, we extended the > PCL-0.7 > source code: > to manage this, we added a 'createRefMap'-function in > cartography/engine/mapserver/mapserver.py and extended > cartography/mapping.py > for a ReferenceMap class. These functions are close to the > mapscript-attributes > and far from intention of independent use of map-engines. Has anyone > better > sugestions for implementing a refernce-map? If someone want's to > improve the > code, please tell us about the changes. > > florian & michael > Hi Florian and Michael, Thanks for the contribution. I'm curious to see what kind of application you are making of PCL. My intention for reference maps has been to not use new classes at all, but simply treat the reference map as another small map: 1. create a raster data store using a small GeoTIFF or georeferenced JPEG, and wrap in a Layer 2. Use an in-memory feature store to hold the main map's view as a rectangle 3. Define a polygon symbolizer for the main map's view 4. Draw these two layers to an image using a PCL map renderer The reason why I want to avoid any more MapServer/mapscript specific code is that I am considering a new mapping engine for PCL based on matplotlib + Agg and/or Agg by itself. See the most recent posts on my news site for an example: http://zcologia.com/news/ Keeping all the mapscript use behind the engine.mapserver.rendering.MapRenderer will make it easier to write engine-independent code for PCL. Back to the idea of a reference map class for PCL ... I want to make it easy to make reference maps and scalebars, but I don't think that such classes really fit in well with PCL. I want PCL to remain at a slightly lower level. The ZCO project, which extends PCL for use with Zope, is an example of where I think reference map and scalebar classes belong -- at the application level and not the library level. cheers, Sean > #### mapserver.py: ########################################### > def createRefMap( mapSize, mapExt, srs, img, refSize, refExt, imgType > = 'PNG'): > """Draw Reference Map""" > mo = mapscript.mapObj() > # set map-attributes > mo.setSize( mapSize[ 0 ], mapSize[ 1 ] ) > mo.setExtent( mapExt[ 0 ], mapExt[ 1 ], mapExt[ 2 ], mapExt[ 3 ] ) > mo.setImageType( imgType ) > mo.setProjection( 'init=%s' % srs ) > # set refMap-attributes > mo.reference.image = img > mo.reference.width = refSize[ 0 ] > mo.reference.height = refSize[ 1 ] > mo.reference.extent.minx = refExt[ 0 ] > mo.reference.extent.miny = refExt[ 1 ] > mo.reference.extent.maxx = refExt[ 2 ] > mo.reference.extent.maxy = refExt[ 3 ] > # box-attributes are default > mo.reference.outlinecolor.setRGB( 255, 0, 0 ) > mo.reference.color.setRGB( -1, -1, -1 ) > # draw image > im = mo.drawReferenceMap() > > image = mapping.Image() > #for the upcoming mapserver function > if hasattr(im, 'getBytes'): > image.data.write(im.getBytes()) > else: > im.write(image.data) > > image.size = [im.width, im.height] > image.mimetype = im.format.mimetype > > del im > del mo > return image > > ### mapping.py: ################################################## > class ReferenceMap: > > """ReferenceMap from createRefMap() in mapserver.py > > Attributes > ---------- > mapSize : list > image.width, image.height of map > > mapExt : list > map bounding box like '[xmin, ymin, xmax, ymax]' > > srs : string > like: 'EPSG=31294' > > img : string > path to image-object like 'context/irmi/img/...' > > refSize: list > image.width, image.height of ReferenceMap > > refExt : list > ReferenceMap bounding box like '[xmin, ymin, xmax, ymax]' > > imgType : string > default is 'PNG' > > """ > > def __init__( self, mapSize, srs, img, refSize, refExt, imgType = > 'PNG' ): > self.__mapSize = mapSize > self.__mapExt = [] > self.__srs = srs > self.__img = img > self.__refSize = refSize > self.__refExt = refExt > self.__imgType = imgType > > def draw( self, mapExt, refExt=None ): > self.__mapExt = mapExt > if refExt: > self.__refExt = refExt > ref = engine.mapserver.mapserver.createRefMap( self.__mapSize, > self.__mapExt, self.__srs, > self.__img, self.__refSize, > self.__refExt, > self.__imgType ) > > return ref > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > ZMapServer-Developers mailing list > ZMa...@li... > https://lists.sourceforge.net/lists/listinfo/zmapserver-developers > > -- Sean Gillies sgillies at frii dot com http://users.frii.com/sgillies |