<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I see that you have found the problem with the selection object as well
:).<br>
I have been quite annoyed with that many times myself.<br>
<br>
You can actually save and restore the RuntimeMap (and selection data).<br>
If you do this, a side effect is that the object id's are not
re-generated.<br>
I use this frequently, because MgMap.Create takes too long in my
solutions.<br>
<br>
To do this, you need to convert the name of the map into a resource id,<br>
eg. mapName = "MAP", the resource id becomes:<br>
Session:<session-id>//MAP.Map<br>
<br>
If you apply GetResourceContent to this, you get an xml document with
"<Map />"<br>
as the only content.<br>
<br>
You must then issue the EnumerateResourceData on the resourceId,<br>
and you should be able to see the map, the layers and the darned
selection resource.<br>
<br>
You can download these with GetResourceData. They are binary objects,<br>
and internal to MapGuide. I have written a helper class to read/write
them here:<br>
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/RuntimeClasses">http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/RuntimeClasses</a><br>
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/BinarySerializer">http://trac.osgeo.org/mapguide/browser/trunk/Tools/Maestro/MaestroAPI/BinarySerializer</a><br>
<br>
You can simply store these files on disk.<br>
When you start a session, you can revert the process, and create the
"<Map />" resource,<br>
and call SetResourceData to upload the files.<br>
<br>
The binary files are a copy of the MapDefinition (and some of the
FeatureSource/LayerDefinition stuff),<br>
so if you change the MapDefinition/LayerDefinition/FeatureSource, you
must re-generate the binary files.<br>
<br>
Using this approach, you can skip the _map.Create call, and thus get
"static" object id's.<br>
If you use the MaestroAPI reader/writer, you can also set the object
id's.<br>
<br>
<pre class="moz-signature" cols="72">Regards, Kenneth Skovhede, GEOGRAF A/S
</pre>
On 22-02-2010 22:08, Pietro Ianniello wrote:
<blockquote
cite="mid:98da27e31002221308h3bc486dcxec4f298e535c910@mail.gmail.com"
type="cite">"Ok, I can see that I misjudged your experience level
completely"<br>
No problem :-), I see that there are many questions about things such
as "Can I use images in MapGuide" and such, wich are all answered in
MapGuide developer guide [wich should be printed and read ,and
re-read... and re-re-read!].<br>
<br>
If you are intersted, you can download the attachment from <br>
<a moz-do-not-send="true"
href="http://n2.nabble.com/Sessions-on-server-side-td4612873.html">http://n2.nabble.com/Sessions-on-server-side-td4612873.html</a><br>
<br>
It assumes MapGuide OS installed in "C:\OSGeo"<br>
so "webconfig.ini" in "<b>C:\OSGeo\MapGuide\Web\www</b>",<br>
with the .NET viewer.<br>
<br>
If it is in another place, the file "<b>MgSheboyganCacheHelper.cs</b>"
at line 61 bust be accordingly changed.<br>
<br>
A better approach is to use the following function (as I do in my
assembly that controls MapGuide):<br>
<br>
<span style="font-family: courier new,monospace;"> //call
CLASSNAME.SetIniPath("/mapguide/");</span><br>
<span style="font-family: courier new,monospace;">public
static void SetIniPath(string strMGVirtualDirectoryPath)</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> {</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> string
physicalpath = <br>
HttpContext.Current.Server.MapPath(strMGVirtualDirectoryPath);</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
_strWebconfigPhysicalInipath = physicalpath + "webconfig.ini";</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
_strIniBasePhysicalPath = physicalpath;</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
_strWebconfigWebInipath = strMGVirtualDirectoryPath + "webconfig.ini";</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">
_strIniBaseWebPath = strMGVirtualDirectoryPath;</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> }</span><br>
<br>
wich assumes the following members [default initialized]:<br>
<br>
<font size="1"><span style="font-family: courier new,monospace;">protected
static string _strWebconfigPhysicalInipath =
"C:\\OSGeo\\MapGuide\\Web\\www\\webconfig.ini";</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">protected static
string _strIniBasePhysicalPath = "C:\\OSGeo\\MapGuide\\Web\\www\\";</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">protected static
string _strWebconfigWebInipath = "<a moz-do-not-send="true"
href="http://localhost/mapguide/webconfig.ini">http://localhost/mapguide/webconfig.ini</a>";</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">protected static
string _strIniBaseWebPath = "<a moz-do-not-send="true"
href="http://localhost/mapguide/">http://localhost/mapguide/</a>";</span></font>
<br>
<br>
My solution works, and I like it.<br>
I only have concerns about scalability: what will MapGuide do when
there are multiple requests with the same session? Will it queue them
properly as if sessons where al different? <br>
<br>
A further explanation on why I use such a thing.<br>
<br>
I use MapGuide with Openlayers. OpenLayers can request
"showLayers","hideLayers". I set up maps with all layers default
invisible. The I "activate" the layers I want to see in javascript
using the two OpenLayers option just mentioned. This could be done on
server side, but in this case the state of the map would be stored in
session [<i style="font-family: courier new,monospace;">layer.SetVisible(true);map.Save();</i>],
and, furthermore, my idea is that if something can be done on the
client, do it on the client and save computation on the server.<br>
<br>
The proble with "showLayers/hideLayers" is that they need "ObjectId" of
the layer. So to give that id you must do something like:<br>
<i>_map.GetLayers().GetItem("<LAYER NAME>").GetObjectId();</i><br>
and this must be done on every session expiration.<br>
So when in my solution [the real, not the posted one] I recreate the
server side mantained "cache" of session, I recreate a list with these
ObjectId.<br>
<br>
If my solution doesn't scale well, the alternative is to recreate
OpenLayers' layers with a new session and store in javascript the new
ObjectIds. This is a lot of work for many reasons it's off topic to
expose. <br>
<br>
I prefer my solution even because shelds me from exposing sessions, and
with "MgSheboyganCacheHelper.cs" I could one day [time permitting]
expose MapGuide only to localhost, using a proxy to access it -
something like "MgSheboyganCacheHelper.cs" but more general.<br>
<br>
This for Anonymous users, and for publicly available sites.<br>
<br>
If one wants to use MapGuide in intranet or to do editing, it's a
different story.<br>
<br>
Regard,<br>
Pietro Ianniello<br>
<br>
P.S.: I could answer to my question by downloading MapGuide sources...
even though I am programming in C#, I come from C++, so it would not be
a problem, but I think it would requre HUGE ammount of time! And now I
don't have it...<br>
<br>
P.P.S.: [out of topic] It would be nice if somwhere there is some info
about updating FDO with the current MG OS. For example usng FDO 3.4.1
instead of 3.4.0... I say this in perspective... I am very intersted in
PostGIS, and anxious to see and test a good implementation, because now
it's not usable [seems FDO 4.5 will, If I understand - <a
moz-do-not-send="true" href="http://trac.osgeo.org/fdo/wiki/FDORfc45">http://trac.osgeo.org/fdo/wiki/FDORfc45</a>
- if that 45 stands for 4.5].<br>
<br>
<div class="gmail_quote">P.P.P.S.: I anwered 2 times before, because <span
class="gI"><span class="gD" style="color: rgb(91, 16, 148);">Mail
Delivery System</span> <span class="go"><<a moz-do-not-send="true"
href="mailto:MAILER-DAEMON@lists.osgeo.org">MAILER-DAEMON@lists.osgeo.org</a>>
continues to tell me that:</span></span><br>
<span style="font-family: courier new,monospace;"> I'm
sorry to have to inform you that your message could not</span><br
style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> be
delivered to one or more recipients. It's attached below.</span><br
style="font-family: courier new,monospace;">
Don't know why...<br>
</div>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
mapguide-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:mapguide-users@lists.osgeo.org">mapguide-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/mapguide-users">http://lists.osgeo.org/mailman/listinfo/mapguide-users</a>
</pre>
</blockquote>
</body>
</html>