|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorHi everyone,
I am currently developing a Python-Mapscript based web-mapping framework (http://dracones.surveillance.mcgill.ca) that worked very well with earlier versions of MS (MS4W < 3 on Windows, and MS ~ 5.2 on Linux). This week I started playing with Python 2.6, and so it lead me to the latest beta of MS4W, which I read has a version of Python-MS built for it. I am currently using the Beta 7. I have noticed a strange behavior with the queryByRect function, different than what was before: when I programmatically add features to a point layer and then try to retrieve a subset of them with queryByRect, getNumResults gives the correct number of retrieved features, but then the set of shapes returned by layer.getFeature(layer.getResult(i).shapeindex) is not right. The best way to explain in what way is isn't right is this example: when I query for three very distinct features, what I get is this: [<mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x01EC71E0> >, <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x01EC71C0> >, <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x01EC71E0> >] The first and third objects seem to be the same, according to their pointers. No matter what query I try to perform, there is always a similar problem occurring: some pointers seem to be pointing to shared objects, whereas they shouldn't (at least from what I understand). I understand that this problem description may not be terribly helpful since it may be hard to reproduce, but since it would take time to abstract away the suspicious code in my framework, I thought that I would go for the high-level first, in case I am missing something obvious. Thanks in advance for any help, Christian _______________________________________________ MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
|
|
Re: MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorChristian Jauvin wrote:
> Hi everyone, > > I am currently developing a Python-Mapscript based web-mapping > framework (http://dracones.surveillance.mcgill.ca) Interesting! When your new framework is ready for distribution please email me directly and we'll add it to the MS4W downloads page. -jeff -- Jeff McKenna FOSS4G Consulting and Training Services http://www.gatewaygeomatics.com/ _______________________________________________ MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
|
|
Re: MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorHi,
Following the problem description I posted last week, I have created a very simple test case: the attached Python script creates first a map by reading the attached mapfile, and then add five distinct point features to its only layer. It then performs a queryByRect that encompasses the whole layer (certain to retrieve the five features) and prints the results. On a Linux box running Python-MS 5.0, the results are: <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8cf600> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d28a0> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2a30> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2c00> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2dd0> > Five distinct objects, which is what is expected, whereas the same script running on Windows with the latest version of MS4W (3b7, thus running Python-MS 5.4), I get: <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DAE0> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DAE0> > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > The problem I was describing is apparent here: the five features seem to be sharing in fact only two different objects (based on their pointer values). I am not familiar enough with the bowels of MapServer to be able to debug this problem by myself, so again, any help would be greatly appreciated. Christian On Fri, Nov 6, 2009 at 11:20 AM, Christian Jauvin <cjauvin@...> wrote: > Hi everyone, > > I am currently developing a Python-Mapscript based web-mapping > framework (http://dracones.surveillance.mcgill.ca) that worked very > well with earlier versions of MS (MS4W < 3 on Windows, and MS ~ 5.2 on > Linux). This week I started playing with Python 2.6, and so it lead me > to the latest beta of MS4W, which I read has a version of Python-MS > built for it. I am currently using the Beta 7. > > I have noticed a strange behavior with the queryByRect function, > different than what was before: when I programmatically add features > to a point layer and then try to retrieve a subset of them with > queryByRect, getNumResults gives the correct number of retrieved > features, but then the set of shapes returned by > layer.getFeature(layer.getResult(i).shapeindex) is not right. The best > way to explain in what way is isn't right is this example: when I > query for three very distinct features, what I get is this: > > [<mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at > 0x01EC71E0> >, > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at > 0x01EC71C0> >, > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at > 0x01EC71E0> >] > > The first and third objects seem to be the same, according to their > pointers. No matter what query I try to perform, there is always a > similar problem occurring: some pointers seem to be pointing to shared > objects, whereas they shouldn't (at least from what I understand). > > I understand that this problem description may not be terribly helpful > since it may be hard to reproduce, but since it would take time to > abstract away the suspicious code in my framework, I thought that I > would go for the high-level first, in case I am missing something > obvious. > > Thanks in advance for any help, > > Christian > from mapscript import * m = mapObj('querybyrect_problem.map') layer = m.getLayerByName('point_layer') def addPoint(layer, x, y): pt_shape = shapeObj(MS_SHAPE_POINT) pt_shape.index = 0 line = lineObj() line.add(pointObj(x, y)) pt_shape.add(line) layer.addFeature(pt_shape) addPoint(layer, 270000.0, 5030000.0) addPoint(layer, 270001.0, 5030001.0) addPoint(layer, 270002.0, 5030002.0) addPoint(layer, 270003.0, 5030003.0) addPoint(layer, 270004.0, 5030004.0) rect = rectObj(200000.0, 5000000.0, 400000.0, 5500000.0) succ = layer.queryByRect(m, rect) features = [] if succ == MS_SUCCESS: n_res = layer.getNumResults() for j in range(n_res): res = layer.getResult(j) shp = layer.getFeature(res.shapeindex) features.append(shp) for f in features: print f _______________________________________________ MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
|
|
Re: MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorChristian Jauvin wrote:
> Hi, > > Following the problem description I posted last week, I have created a > very simple test case: the attached Python script creates first a map > by reading the attached mapfile, and then add five distinct point > features to its only layer. It then performs a queryByRect that > encompasses the whole layer (certain to retrieve the five features) > and prints the results. On a Linux box running Python-MS 5.0, the > results are: > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8cf600> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d28a0> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2a30> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2c00> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2dd0> > > > Five distinct objects, which is what is expected, whereas the same > script running on Windows with the latest version of MS4W (3b7, thus > running Python-MS 5.4), I get: > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DAE0> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DAE0> > > <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > > > The problem I was describing is apparent here: the five features seem > to be sharing in fact only two different objects (based on their > pointer values). > > I am not familiar enough with the bowels of MapServer to be able to > debug this problem by myself, so again, any help would be greatly > appreciated. > Hello Christian, You might also test with MapServer 5.6 beta5, which you can also find on the MS4W downloads page, as an add-on package. Also, you could try another MapServer package on Windows (such as http://fwtools.maptools.org/). If you only see your issue when using MS4W, then you can file a ticket in MS4W's tracker (http://bugzilla.maptools.org/query.cgi?GoAheadAndLogIn=1). Thanks. -jeff -- Jeff McKenna FOSS4G Consulting and Training Services http://www.gatewaygeomatics.com/ _______________________________________________ MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
|
|
Re: MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorHi Jeff,
I tried the MS 5.6 beta 5 patch for MS4W and it solves the problem (if there was one!). I guess my diagnostic test case was not relevant on the other hand, because although my framework now behaves correctly, the behavior I observed and reported in the previous message (with the test Python script) is again the same (distinct features that share the same pointer). I don't know what it means, but it now works. Thanks for the suggestion, I can now resume working on my framework. Christian On Mon, Nov 9, 2009 at 7:34 AM, Jeff McKenna <jmckenna@...> wrote: > Christian Jauvin wrote: >> Hi, >> >> Following the problem description I posted last week, I have created a >> very simple test case: the attached Python script creates first a map >> by reading the attached mapfile, and then add five distinct point >> features to its only layer. It then performs a queryByRect that >> encompasses the whole layer (certain to retrieve the five features) >> and prints the results. On a Linux box running Python-MS 5.0, the >> results are: >> >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8cf600> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d28a0> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2a30> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2c00> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x8d2dd0> > >> >> Five distinct objects, which is what is expected, whereas the same >> script running on Windows with the latest version of MS4W (3b7, thus >> running Python-MS 5.4), I get: >> >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DAE0> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DAE0> > >> <mapscript.shapeObj; proxy of <Swig Object of type 'shapeObj *' at 0x00B6DB40> > >> >> The problem I was describing is apparent here: the five features seem >> to be sharing in fact only two different objects (based on their >> pointer values). >> >> I am not familiar enough with the bowels of MapServer to be able to >> debug this problem by myself, so again, any help would be greatly >> appreciated. >> > > Hello Christian, > > You might also test with MapServer 5.6 beta5, which you can also find on > the MS4W downloads page, as an add-on package. > > Also, you could try another MapServer package on Windows (such as > http://fwtools.maptools.org/). > > If you only see your issue when using MS4W, then you can file a ticket > in MS4W's tracker > (http://bugzilla.maptools.org/query.cgi?GoAheadAndLogIn=1). > > Thanks. > > -jeff > > > > > -- > Jeff McKenna > FOSS4G Consulting and Training Services > http://www.gatewaygeomatics.com/ > > > > > > _______________________________________________ > MS4W-Users mailing list > MS4W-Users@... > http://lists.maptools.org/mailman/listinfo/ms4w-users > MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
|
|
Re: [mapserver-dev] Re: MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorChristian Jauvin wrote:
> if succ == MS_SUCCESS: > n_res = layer.getNumResults() > for j in range(n_res): > res = layer.getResult(j) > shp = layer.getFeature(res.shapeindex) > features.append(shp) > Note that starting with MapServer 5.6, when reading shapes out of a resultset, you should use the new layer.resultsGetShape() method instead of layer.getShape() or layer.getFeature(). Your script creates and queries inline features, and in this case the old method still works, but for PostGIS, Oracle and SDE data sources that is an important change to make. More info in the 5.6 migration guide (draft) at http://trac.osgeo.org/mapserver/browser/trunk/mapserver/MIGRATION_GUIDE.TXT Daniel -- Daniel Morissette http://www.mapgears.com/ _______________________________________________ MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
|
|
Re: [mapserver-dev] Re: MS4W Beta 7 -- Python-Mapscript -- queryByRect strange behaviorHi Daniel,
Thanks for the note: of course I ran into the issue a little bit later (I simply had not reached yet the part of my program that deals with PostGIS layers), and I was quite happy to be aware of that! Now I really tried to figure how to upgrade my < 5.6 code with the new query mechanism that you added in 5.6, but (1) I couldn't find enough documentation/example about the issue (I understand it is pretty new) and (2) couldn't make enough sense of what I read in the MS 5.6 C source that I downloaded. I cannot even figure out the exact arguments to the method (as they are not explictly stated in the SWIG generated code). If you would have time to provide a little example showing how it works, it would be greatly appreciated! Thanks, Christian On Mon, Nov 9, 2009 at 2:46 PM, Daniel Morissette <dmorissette@...> wrote: > Christian Jauvin wrote: >> if succ == MS_SUCCESS: >> n_res = layer.getNumResults() >> for j in range(n_res): >> res = layer.getResult(j) >> shp = layer.getFeature(res.shapeindex) >> features.append(shp) >> > > Note that starting with MapServer 5.6, when reading shapes out of a > resultset, you should use the new layer.resultsGetShape() method instead > of layer.getShape() or layer.getFeature(). > > Your script creates and queries inline features, and in this case the > old method still works, but for PostGIS, Oracle and SDE data sources > that is an important change to make. > > More info in the 5.6 migration guide (draft) at > http://trac.osgeo.org/mapserver/browser/trunk/mapserver/MIGRATION_GUIDE.TXT > > Daniel > -- > Daniel Morissette > http://www.mapgears.com/ > _______________________________________________ > MS4W-Users mailing list > MS4W-Users@... > http://lists.maptools.org/mailman/listinfo/ms4w-users > MS4W-Users mailing list MS4W-Users@... http://lists.maptools.org/mailman/listinfo/ms4w-users |
| Free embeddable forum powered by Nabble | Forum Help |