Re: [mapserver-users] Getting introduced to MapScript
On 3 August 2012 13:34, Cristiano Sumariva sumar...@gmail.com wrote: You can set the type and data attributes directly, in fact you need do that for the layerobj works properly. After you create the layerobj you need set those attributes directly. How to set them depends on language you use. With PHP Mapscript you can do this ( that would be similar to other languages ): $layer = ms_newLayerObj( mapOwner ); // here the weird thing the layerObj constructor did not set the layer type not even required it to initialize the layerobj. $layer-set( 'type', MS_LAYER_POLYGON ); $layer-set( 'data', '/absolute/or/../relative/toyourfile.gml' ); Dear Cristiano, thank you for the reply. As you can see below, the set method is raising exceptions when I invoke it the way you suggest. Apparently, attributes like NAME or SHAPEPATH are unknown to MapScript. This was run directly in the Python console. Any other suggestions are welcome. Thank you, Luís from mapscript import * mapObj = mapObj() mapObj.setExtent(91979,436326,92617,437659.5) 0 mapObj.setProjection(epsg:28992) 0 newLayer = layerObj(mapObj) newLayer.setMetaData(DESCRIPTION, MyLayer) 0 newLayer.setMetaData(ows_title, MyLayer) 0 newLayer.set(NAME, MyLayer) Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.7/dist-packages/MapScript-6.0.1-py2.7-linux-x86_64.egg/mapscript.py, line 1192, in lambda __getattr__ = lambda self, name: _swig_getattr(self, layerObj, name) File /usr/local/lib/python2.7/dist-packages/MapScript-6.0.1-py2.7-linux-x86_64.egg/mapscript.py, line 34, in _swig_getattr raise AttributeError,name AttributeError: set NameError: name 'self' is not defined mapObj.set(SHAPEPATH, /tmp/shapes) Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.7/dist-packages/MapScript-6.0.1-py2.7-linux-x86_64.egg/mapscript.py, line 1434, in lambda __getattr__ = lambda self, name: _swig_getattr(self, mapObj, name) File /usr/local/lib/python2.7/dist-packages/MapScript-6.0.1-py2.7-linux-x86_64.egg/mapscript.py, line 34, in _swig_getattr raise AttributeError,name AttributeError: set ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Getting introduced to MapScript
Thank you Stephen, loading an existing MapFile and looking into its contents should help indeed, but it is a bit frustrating to see such basic things lacking in the documentation. In any case, I'd ask again if this is the right place to ask help for on MapScript, or if there's another forum dedicated to it. Thank you, Luís -- View this message in context: http://osgeo-org.1560.n6.nabble.com/Getting-introduced-to-MapScript-tp4992463p4992863.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Getting introduced to MapScript
Hi Cristiano, thank you for the reply. I'm precisely trying to build a wrapper API for the specific where you a GML file and want to automatically publish it through MapServer. If I understand correctly from your message there is no way set the layer TYPE attribute directly. Is this the same with the DATA attribute? In such case how can it be set? Thank you, Luís On 2 August 2012 14:37, Cristiano Sumariva sumar...@gmail.com wrote: Well if you have time to do it, I strong suggest you to create a thin wrapper about mapscript. This is for case you can have a safe, programmer friendly API. Or at least create a Factory class for some mapscript constructs. This will save you of much trouble in future when you going need change something. For your commented object layerObj the mapscript function or method to creating a new layer would be new layer( parent ). What would lead you to map draw failure because layerobj type was not set. So use a factory like LayerFactory.createPolygon( mapobj ) that will set things properly. I guess the minimum mapfile stuff required are: - map size output - map ground coordinates position - one layer obj( a lot of attributes set here ) -- one class at layerobj( a few atrtibutes set here ) --- one style at above class( presentation, color stuff here ) optional if going work with different projections - the map projetion attribute - for each layer the projection attribute. Again would be very nice to have a wrapper that raise error you if have a layer without projection attribute in presence of it at map object. -- View this message in context: http://osgeo-org.1560.n6.nabble.com/Getting-introduced-to-MapScript-tp4992463p4992866.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Getting introduced to MapScript
On 8/3/2012 3:49 AM, Luís de Sousa wrote: Thank you Stephen, loading an existing MapFile and looking into its contents should help indeed, but it is a bit frustrating to see such basic things lacking in the documentation. In any case, I'd ask again if this is the right place to ask help for on MapScript, or if there's another forum dedicated to it. Yes, there are a lot of mapscript developers here and I'm sure we will be happy to answer questions. FYI, since you are using Python mapscript you want to look at the SWIG mapscript API. There are small differences between SWIG and PHP flavors of mapscript so just be forewarned. -Steve W ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Getting introduced to MapScript
Hi Stephen, thank you for the reply. Yes I've went through those pages already. There you learn a few things, but not how to set up a MapFile entirely. How to set up the SHAPEPATH for a mapObj for instance, or the DATA and TYPE for a layerObj. I'm presently using Python, not that I like the language, but I've been learning quite a bit with the MapScript code in PyWPS. Luís -- View this message in context: http://osgeo-org.1560.n6.nabble.com/Getting-introduced-to-MapScript-tp4992463p4992604.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Getting introduced to MapScript
On 8/2/2012 3:10 AM, Luís de Sousa wrote: Hi Stephen, thank you for the reply. Yes I've went through those pages already. There you learn a few things, but not how to set up a MapFile entirely. How to set up the SHAPEPATH for a mapObj for instance, or the DATA and TYPE for a layerObj. I'm presently using Python, not that I like the language, but I've been learning quite a bit with the MapScript code in PyWPS. The rules for setting SHAPEPATH, DATA, and TYPE are all defined in the mapfile documentation. There are no separate rules because you are using mapscript. Typically if I were building a mapscript application, I would start with a static mapfile and make sure that works. Then you can load that and examine it using mapscript to see what various objects look like. From there you can start looking into building objects dynamically. I also think there is method that lets you save you mapfile to a file. This would be helpful if you are building a mapfile dynamically so you can see what you have built at any given moment that you save it. Beyond that, it have been I while since I have written an mapscript applications, so I'm not sure how much more help I can be. Please consider making patches to improve the docs and posting pull requests, or at least writing a ticket with you updated information. Thanks, -Steve W ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Getting introduced to MapScript
On 8/1/2012 11:14 AM, Luís de Sousa wrote: Dear all, I'm starting to dive into MapScript but am feeling a bit lost. The documentation is scant and so far I haven't been able to find a proper API reference. Right now I'm just going through the code itself and things are going rather slowly. Is there a thorough API reference out there? And where is the right place to ask for help? Here at this forum? I assume you are already looking at this: http://mapserver.org/mapscript/index.html#mapscript http://mapserver.org/mapscript/php/by_example.html Which flavor of mapscript are you using? PHP, C#, etc -Steve W ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users