I would try using:
$routeFeatureSourceName = 'Session:'.$sessionId."//
PostGisData.FeatureSource";
Also make sure to use a layer definition with a similar id,
'Session:'.$sessionId.'//PostGisLayer.LayerDefinition'
and set it's ResourceId to point at the $routeFeatureSourceName when
creating the XML for the layer definition.
There is no problem using session based resources in a map.
Cheers
Paul
On 26-Jul-07, at 12:36 PM, Scott, Brian wrote:
Hi Paul -
Thanks for the ideas. My code was based on the developer guide /
shebogoyan sample code provided with the install.
More or less I took the sample code, modified it for my use to get
one layer to show up, then cloned the functionality to get it to
work for several layers. There is one big difference between the
sample program and what I've written, namely that due to problems
with filtering on a layer w/PostGIS, I am querying an existing
feature of points, getting the lat long, and then creating points
on the fly using those values, creating new layers based on the
properties of each point, and putting the layers back into the
repository.
I'm not sure I am explicity cloning a feature from the library and
associating it into the session or not.
(Apologies in advance for this being so long winded)
At a high level, here is what I'm doing:
1) Collecting user input.
2) Identifying records in the db that fit the users selection
criteria. These records have lat long and geometry associated with
them.
3) Create a resource service:
$resourceService = $siteConnection->CreateService
(MgServiceType::ResourceService);
3) Create a feature service for each type of point / layer I need
to create:
$routeFeatureService = $siteConnection->CreateService
(MgServiceType::FeatureService);
4) Open the map.
5) Create a class definition for each type of point / layer I need
to create.
6) Define class properties for each class created.
7) Create a feature schema for each class, and associating the
class definition to it.
$routeFeatureSchema = new MgFeatureSchema($routeSchemaName, "Point
schema for Routes");
$routeFeatureSchema->GetClasses()->Add($routeClassDefinition);
8) Creating resource identifiers:
$routeFeatureSourceName = 'Library://COT_WebViewer/BaseMap/Data/
PostGisData.FeatureSource';
$routeResourceIdentifier = new MgResourceIdentifier
($routeFeatureSourceName);
Here, I am using the 'Library:' prefix, but it seems to be
necessary. (?) If I don't put a valid path, but try 'Session:'
instead, it bombs out.
9) Creating sdf parameters
$sdfParams = new MgCreateSdfParams("ArbitraryXY", $wkt,
$routeFeatureSchema);
10) Creating a new feature source:
$routeFeatureService->CreateFeatureSource
($routeResourceIdentifier, $sdfParams);
*? Do I need to perform an additional operation at this point to
have the resultant feature source associated with the session only?*
11) Looping through database results, create points of appropriate
types, add them to property collections.
12) Adding the property collections to the feature source:
$cmd = new MgInsertFeatures($routeClassDefName,
$routeBatchPropertyCollection);
$routeFeatureCommandCollection = new
MgFeatureCommandCollection();
$routeFeatureCommandCollection->Add($cmd);
$routeFeatureService->UpdateFeatures($routeResourceIdentifier,
$routeFeatureCommandCollection, false);
? Is this final call modifying the features in the library and
not the session?
13) Create a new layer definition, and layer resource. Add the
layer resource to the map.
14) Save the map back to the session repository:
$sessionIdName = "Session:".$sessionId."//COT_Utilities.Map";
$sessionResourceID = new MgResourceIdentifier($sessionIdName);
$sessionResourceID->Validate();
$map->Save($resourceService, $sessionResourceID);
Any and all insight is appreciated!
-pD
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Paul
Spencer
Sent: Thursday, July 26, 2007 11:11 AM
To: MapGuide Users Mail List
Subject: Re: [mapguide-users] Map Layers Transferring Between Users
Hi pD,
it sounds as if you are modifying something in the Library:// rather
than making a copy in the Session:// and modifying it there (either
your Layer or FeatureSource I'd guess). Perhaps you could describe
what the code does (in general terms) and we might be able to point
out where you should be using the Session instead.
Cheers
Paul
On 25-Jul-07, at 4:23 PM, passionlessDrone wrote:
Hello friends -
We've created a piece to dynamically add layers and points based on
human
input. If the user submits input for which there is no matching
criteria,
we make no modifications to the map, but I still call
GetMapFrame().Refresh(). Great. However, if two humans are
running the
report, the following can happen:
1) User A runs a report with successful criteria that returns with
points
and new layers. They are displayed correctly on the map at refresh
time.
2) User B runs a report with successful criteria that returns with
points
and new layers. They are displayed correctly on the map at refresh
time.
2) User A runs a report without succesful crieteria that makes no
modifications to the base map.
3) User A's map refreshes, and he sees the new layers / points that
User B
sees.
User A and User B are logged in as separate entities and debugging
validates
that they have separate session id values. The layer names are
the same
between the two users.
I suppose I could just write something that when no criteria match
I get the
map, get the layers, and strip out any that fit the criteria that
the layers
that he 'shouldn't' see, but this is more like hiding the problem
than
understanding it and fixing it. I guess I'm also not sure if this
might
impact another user.
Any insight is greatly appreciated!
-pD
--
View this message in context: http://www.nabble.com/Map-Layers-
Transferring-Between-Users-tf4147718s16610.html#a11799272
Sent from the MapGuide Users mailing list archive at Nabble.com.
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
+-----------------------------------------------------------------+
|Paul Spencer [EMAIL PROTECTED] |
+-----------------------------------------------------------------+
|Chief Technology Officer |
|DM Solutions Group Inc http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
**********************************************************************
**************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals &
computer viruses.
**********************************************************************
**************
**********************************************************************
**************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals &
computer viruses.
**********************************************************************
**************
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users
+-----------------------------------------------------------------+
|Paul Spencer [EMAIL PROTECTED] |
+-----------------------------------------------------------------+
|Chief Technology Officer |
|DM Solutions Group Inc http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+
_______________________________________________
mapguide-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapguide-users