[mapguide-users] Getting all object Enveloppe

David Hequet david.hequet at free.fr
Thu Jun 7 03:44:00 EDT 2007


and about "Select Envelope(geometry) from datasource"
I can do that with ExecuteSqlQuery ?
do you have a syntaxe sample? i think i have to check if the fdoprovider has
this "SpatialExtents" capability? 
going through each object can be very slow on each map loading..


Kenneth, GEOGRAF A/S wrote:
> 
> Yes, you have to run through each feature in the feature reader.
> Then on each feature, you have to use some of the obscure 
> AgfReader/Bytereader stuff to get the actual object out of the geometry 
> column.
> When you have the object, it has a GetEnvelope() method.
> 
> Regards, Kenneth, GEOGRAF A/S
> 
> 
> David Hequet wrote:
>> Arg, i was so close of my goal
>>
>> I think i have to take a look on your idea because of MGSelection seems
>> to
>> have a limit.
>>
>> here is my code:
>>
>> For i = 0 To aMgLayerCollection.GetCount() - 1
>>     aLayer = aMgLayerCollection.GetItem(i)
>>     aProvider = Me._getLayerSourceType(, aLayer)
>>     If aProvider <> "Autodesk.Raster" And aProvider <> "DWF" Then
>>
>>         aLayerClassName = aLayer.GetFeatureClassName()
>>         If aClassArray.IndexOf(aLayerClassName) = -1 Then
>>             Me._log(aLayerClassName)
>>             aLayerFeatureId = aLayer.GetFeatureSourceId()
>>             aLayerResId = New MgResourceIdentifier(aLayerFeatureId)
>>             aFeatureReader =
>> Me._featureService.SelectFeatures(aLayerResId,
>> aLayerClassName, aMGQueryOptions)
>>             aMGSelection.AddFeatures(aLayer, aFeatureReader, 0)
>>             aClassArray.Add(aLayerClassName)
>>         End If
>>     End If
>> Next i
>> aMgEnveloppe = aMGSelection.GetExtents(Me._featureService)
>> I got an error:
>> Une exception non classifiée s'est produite.Une exception non classifiée
>> s'est produite.
>> Une exception s'est produite dans la méthode
>> MgServerSelectFeatures.SelectFeatures à  la ligne 217 dans le fichier
>> c:\build_tux_area\mgdev\server\src\services\feature\ServerSelectFeatures.cpp
>> In english "non classified error"
>> When i use this method
>> aMgEnveloppe = aMGSelection.GetExtents(Me._featureService)
>>
>> it didn't happen every time: 
>> on a map with ~30 features dispatched on 4 layers it's ok
>> on a map with ~1200 features on 2 layers it crash (if i try too much the
>> mgserver service crash).
>>
>> i didn't see a getExtent method on the featurereader, i think i have to
>> check enveloppe for each feature in the reader?
>>
>>
>> Kenneth, GEOGRAF A/S wrote:
>>   
>>> You don't have to use the selection part.
>>> You can extract the object directly from the feature reader.
>>> Once you have the object, you can also get the extent (aka bbox).
>>> If you then construct an envelope object, you can add the features 
>>> envelope to original envelope.
>>>
>>> Something like:
>>>
>>> create a new MgFeatureQueryOptions with an empty filter
>>> create a new Envelope
>>> For Each Layer
>>> {
>>>    Use a featureReader with the MgFeatureQueryOptions
>>>    Add the feature's envelope to the outer Envelope
>>> }
>>> Get zoom extents from the Envelope
>>>
>>>
>>> Other than this, I don't think you can optimize it anymore, as you need 
>>> to execute the query on each layer.
>>>
>>> I think there is a "Get Extents" on the feature source, but I can't find 
>>> it. And I don't think it works on filtered datasources.
>>>
>>> Perhaps you can execute the query with some SQL optimizations like 
>>> "Select Envelope(geometry) from datasource".
>>>
>>> Hope it helps.
>>>
>>> Regards, Kenneth, GEOGRAF A/S
>>>
>>>
>>>
>>> David Hequet wrote:
>>>     
>>>> Hello,
>>>>
>>>> I'm trying to make a fonction that can return me the enveloppe of the
>>>> entire
>>>> visible map (no way with original map extent).
>>>>
>>>> Explain: I have a map "template" with a lot of layers, i have a
>>>> function
>>>> that change all the layer filter (basic filter, no spatial) to see
>>>> different
>>>> map based on that template. Doing that make the "zoom to original
>>>> extent"
>>>> useless, because data are not on the same area.
>>>> I wan't to set the new map extent in the MapDefinition. 
>>>> My ask is about getting the new extent.
>>>>
>>>> I thought to do it like that:
>>>>
>>>> create a new MgSelection
>>>> create a new MgFeatureQueryOptions with an empty filter
>>>> For Each Layer
>>>> {
>>>>    Use a featureReader with the MgFeatureQueryOptions
>>>>    Add the selected feature to the MgSelection
>>>> }
>>>> Getting the MgSelection enveloppe
>>>>
>>>> It will work, but i don't think it's very optimized with a lot of
>>>> Layer/Feature (and it will used at each map load, filter
>>>> modification..)
>>>>
>>>> Did someone have a better way?
>>>>
>>>> Thank you!
>>>>
>>>> Ps: sorry for my poor english, ask i you want precision.
>>>>   
>>>>       
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>
>>>
>>>     
>>
>>   
> 
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
> 
> 

-- 
View this message in context: http://www.nabble.com/Getting-all-object-Enveloppe-tf3864317s16610.html#a11003408
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list