[mapguide-users] DWF Viewer API for managing selections

Andy Morsell amorsell at spatialgis.com
Thu May 4 19:30:30 EDT 2006


That's good information, thanks Traian.  I guess the point I'm trying to
make is that the internally generated FeatId, either encoded or not, really
only matters to FDO.  For example: a parcel Shape file obtained from a
County usually has minimal information in it for mapping purposes.  There is
usually a parcel ID or tax ID of some sort.  Often, we would then generate
reports from a completely external database that contains the tax records
where the parcel ID would also exist.  Unfortunately, to get that parcel ID
from the Shape file via an MGOS selection, one has to programmatically
re-query the data while filtering on the feature ID to get it. 

Andy 

-----Original Message-----
From: Traian Stanev [mailto:traian.stanev at autodesk.com] 
Sent: Thursday, May 04, 2006 4:11 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] DWF Viewer API for managing selections


Not sure how helpful this will be, but... the MapGuide feature ID is a base
64 encoded version of the actual feature key (that comes from FDO). If you
run it through a base 64 decoder, you will get the binary original back. It
will be in little-endian format.

To see how the web extensions code decodes this for use with feature
queries, look at MgSelection::GenerateFilter, starting at a line saying
m_stream->FromBase64(). If you have the MgSelection object and one selected
feature, you could probably call this directly to get your feature id back
in a string.

To see how the feature ID is encoded, look in KeyEncode.cpp (less useful,
but good for information if you want to roll your own decoder).

All this get more complicated when you use more than one attribute as the
feature key, but this is rare.

Traian


-----Original Message-----
From:	Andy Morsell [mailto:amorsell at spatialgis.com]
Sent:	Thu 5/4/2006 6:49 PM
To:	users at mapguide.osgeo.org
Cc:	
Subject:	RE: [mapguide-users] DWF Viewer API for managing selections

Regarding: "Can I somehow configure what the feature ID of a feature source
is based on?"  I had this same question when setting up some functions to
emulate MapGuide 6.5 reporting functionality and determined that the answer
is "no".  In this case, the source data in MGOS is completely disparate from
an external database (and joins did not work back then).  I was using some
existing ASP reports from a MG6.5 site that accepted Parcel ID's as URL
parameters.  In order to accomplish this, I had to use the API to get the
selection set, then use the FDO API to query the MGOS datasource to extract
the Parcel ID's that were in the datasource based on the Feature ID's and
then pass that on to the external report.  
 
That's a lot of overhead for a simple function.  I would much rather be able
to specify on a layer by layer basis what I want MY key field to be (much
like the old MapGuide).  If the internal Feature ID also needs to come along
for the ride, then so be it.  This is also a problem with the
$CurrentSelection parameter when using the Invoke URL command option in
Studio.  In many cases, the Feature ID obtained from the selection is not
going to do the developer any good and they will have to add the step to go
get meaningful values.
 
 
Andy Morsell, P.E. 
Spatial Integrators, Inc. 
http://www.SpatialGIS.com 
 

  _____  

From: Joel Carranza [mailto:jec at gatekeeper.com]
Sent: Thursday, May 04, 2006 3:12 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] DWF Viewer API for managing selections


My end goal is to emulate 6.5 behavior in that i need to able to select
objects via map key and get the selected objects's map key. The problem I
see is that the feature ID appears to be some kind of internal ID and not
related back to a user specified property of the feature source (say for
example the PK of the database row). As such, I have no way to tie my data
to a feature on the map. Making an additional server side call seems kindof
ridiculous. 
 
So my question is this:
- Can I somehow configure what the feature ID of a feature source is based
on? How do you currently generate feature IDs ? 
- We are willing to accept the limitation of only selecting/getting the
selection of onscreen objects. How can I access attribute data for the
features that are currently visible on the screen?
 
Thanks,
--Joel

  _____  

From: Walt Welton-Lair [mailto:walt.welton-lair at autodesk.com] 
Sent: Thursday, May 04, 2006 2:44 PM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] DWF Viewer API for managing selections


The selection set will be a collection of IAdEMapInstance objects.  Each
object has three properties:
    - LayerObjectId    the unique ID of the layer containing the instance
    - ObjectClass      the feature class
    - Id                     the feature ID
 
You cannot directly access the attributes of features through the DWF Viewer
API.  That's because the viewer only stores data (graphical + attributes)
for the features currently visible on the screen.  This is one of the major
differences between MapGuide 6.5 and MapGuide OS.  Note also that the
selection set is persistent.  If you select a feature, pan the view so it's
offscreen, and then pan the view so its onscreeen again then you'll still
see it selected.  The IAdEMapInstance objects provide the minimum
information needed to uniquely identify a feature, and are what allow this
persistent selection behavior.
 
If you want to obtain the attributes of a feature, then you'll need to go
beyond the DWF Viewer API and make a SelectFeatures feature service request.

  _____  

From: Joel Carranza [mailto:jec at gatekeeper.com] 
Sent: Tuesday, May 02, 2006 4:02 PM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] DWF Viewer API for managing selections



I am trying to write some code to inspect the current selection using the
DWF Viewer. However, I am unable to find any documentation on what comes out
of the "selectionSet" property of the viewer. I see that it is a collection
of some kind, but I don't know what the type that comes out of the
collection is. I consulted the "Viewer APIs for Emap" document but didn't
see any relevant information. 

The code I am using is something like the following: 

    var selectionSet = emapViewer.SelectionSet; 
    
    for(selEnumerator = new Enumerator(selectionSet);
!selEnumerator.atEnd(); selEnumerator.moveNext()) 
    { 
        var feature = selEnumerator.item(); 
        var id = feature.id; 
        var layerId = feature.LayerObjectId; 
        // what is feature? 
        // what are its properties and methods?       
    } 

Specifcally, I want programmatic access to the object properties that are
shown in the properties pane. Anybody know how to do this?

--Joel 











More information about the Mapguide-users mailing list