mapscript ShapeObj object with postgis layers with c#

Szekeres Tamás szekeres.tamas at FREEMAIL.HU
Thu May 4 05:48:04 EDT 2006


Hi,

Here is a sample code should work for the postgis layers as
well:



private void DumpResults(layerObj layer)
{
	resultCacheMemberObj res;
	shapeObj feature;
	using (resultCacheObj results = layer.getResults())
	{
		if (results != null && results.numresults > 0)
		{
			// extracting the features found
			layer.open();
			for (int j=0; j < results.numresults; j++)
			{
				res = results.getResult(j);
				feature = layer.getFeature(res.shapeindex, res.tileindex);
				if (feature != null)
				{
					Trace.WriteLine(layer.name + " (" + feature.index + ")");
					for (int i = 0; i < feature.numvalues; i++)
					{
						Trace.WriteLine(layer.getItem(i) + "=" +
feature.getValue(i));
					}
				}
			}
			layer.close();
		}
	}
}

public void QueryByShape(shapeObj shape)
{
	if (shape != null)
	{
		Trace.WriteLine("The query shape is not specified.");
		return;
	}
	
	try
	{
		if (shape.type == MS_SHAPE_TYPE.MS_SHAPE_POLYGON)
		{
			map.queryByShape(shape);
			layerObj layer;
		
			for (int i = 0; i < map.numlayers; i++)
			{
				layer = map.getLayer(i);
				if (layer.status != mapscript.MS_OFF)
				{
					DumpResults(layer);
				}
			}
		}
		else
		{
			Trace.WriteLine("The query shape must be a polygon.");
		}
	}
	catch (Exception e)
	{
		Trace.WriteLine("QueryByShape error: " + e.Message);
	}
}


Best Regards,

Tamas



On Thu, 4 May 2006 09:48:51 +0200, Xavier Mauclaire
<xavier.mauclaire at GEOTER.FR> wrote:

>Hi
>I'm developping with VS 2003 for windows and mono with c#
plateform
>
>i may have a question cencerning the shapeobj object : Can
i use this object
>with objects coming from Postgis Layers ?
>
>If yes how can i get attributes values (all values are
empty ) ?
>
>May the  function like querybyshape using data from postgis
be retunring
>wrong result (Numresults is wrong) . is there any problems
with postgis
>layer ?
>On the other hand i may be mistaken using this function :-)
>
>Any help will be appreciated
>
>regards
>
>
>-----------------------------------------
>
>Xavier Mauclaire
>
>-------------------------------------------------------
>
>
>
>
>
>



_______________________________________________________________________________
Anyák napja - ugye nem felejti el?
http://www.bookline.hu/control/shlist?id=60&affiliate=freanykar2482





More information about the mapserver-users mailing list