[mapguide-users] Add layer dinamically from search results

yof85 loref85 at yahoo.com.ar
Tue Feb 19 11:03:52 PST 2013


So far I think this is the main part of buffer.aspx that I need to modify

MgFeatureQueryOptions query = new MgFeatureQueryOptions();
query.SetFilter(filter);

MgResourceIdentifier featureSource = new
MgResourceIdentifier(selLayer.GetFeatureSourceId());

MgFeatureReader features = featureSrvc.SelectFeatures(featureSource,
featureClassName, query);

if (features.ReadNext())
{
	MgClassDefinition classDef = features.GetClassDefinition();
	String geomPropName = classDef.GetDefaultGeometryPropertyName();
	do
	{
		MgByteReader geomReader = features.GetGeometry(geomPropName);
		MgGeometry geom = agfRW.Read(geomReader);

		if (merge == 0)
		{
			geomBuffer = geom.Buffer(dist, measure);
			if (geomBuffer != null)
			{
				if (srsXform != null)
					geomBuffer = (MgGeometry)geomBuffer.Transform(srsXform);
				*AddFeatureToCollection(propCollection, agfRW, featId++, geomBuffer);*
				bufferFeatures++;
			}
		}
		else
		{
			if (srsXform != null)
				geom = (MgGeometry)geom.Transform(srsXform);
			inputGeometries.Add(geom);
		}
	}
	while (features.ReadNext());

	features.Close();
}

void *AddFeatureToCollection*(MgBatchPropertyCollection propCollection,
MgAgfReaderWriter agfRW, int featureId, MgGeometry featureGeom)
{
    MgPropertyCollection bufferProps = new MgPropertyCollection();
    MgInt32Property idProp = new MgInt32Property("ID", featureId);
    bufferProps.Add(idProp);
    MgByteReader geomReader = agfRW.Write(featureGeom);
    MgGeometryProperty geomProp = new MgGeometryProperty("GEOM",
geomReader);
    bufferProps.Add(geomProp);
    propCollection.Add(bufferProps);
}

If I'm close, I need to modify the AddFeatureToCollection to add the
selected points of my map, as I stated before, I want to create a new layer
from selected points and I need to keep the layer information in that new
layer

I tried to do something like this instead (based on this:
http://code.google.com/p/mapguide-contrib/source/browse/trunk/Libraries/DotNet/OSGeo.MapGuide.Extensions/OSGeo.MapGuide.Extensions/MgFeatureRepository.cs)

MgFeatureQueryOptions query = new MgFeatureQueryOptions();
query.SetFilter(filter);

MgResourceIdentifier featureSource = new
MgResourceIdentifier(selLayer.GetFeatureSourceId());

MgFeatureReader features = featureSrvc.SelectFeatures(featureSource,
featureClassName, query);

MgClassDefinition classDef = features.GetClassDefinition();
				
string[] propNames = features.GetPropertyNames();
if (features.ReadNext())
{

	MgPropertyCollection res = features.ReadFeature(propNames);
	propCollection.Add(res);
	
}
features.Close();

But I get this error message: 'ReadFeature' doesn't exist in context.

How can I store the selected elements of the map in a
MgBatchPropertyCollection in order to create the new layer?




--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Add-layer-dinamically-from-search-results-tp5033775p5035298.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list