[mapguide-users] Maestro Python api example script setScaleRange for a drawingLayer

lucvanlinden luc.vanlinden at gmail.com
Mon Jan 26 02:06:01 PST 2015


Hi

I have tried to use the ScaleRangeUpdate example python script with Maestro.

Unfortunately this does not work for a DrawingLayer as it does not have a
vectorscalerange.

After a lot of trying I managed to find out that it is possible to call:

ldf.SubLayer.MinScale = min

So we added a new function to the pyton script:

def FixScaleRangesMinMaxDrawing(conn, folder, min, max):
    """
    Modifies the first scale range of all Layer Definitions under the
specified folder to the specified
    minimum and Mmximum scales
    """
    resList = conn.ResourceService.GetRepositoryResources(folder,
"LayerDefinition")
    for child in resList.Children:
        ldf = conn.ResourceService.GetResource(child.ResourceId)
        print "Fixing: %s" % (child.ResourceId)
        # vsr is a IVectorScaleRange instance
        #vsr = ldf.SubLayer.GetScaleRange()
        ldf.SubLayer.MinScale = min
        # MinScale is a nullable property, so you also need to set the
respective MinScaleSpecified property to true
        # in order for this change to be persisted
        ldf.SubLayer.MaxScale = max
        # MaxScale is a nullable property, so you also need to set the
respective MaxScaleSpecified property to true
        # in order for this change to be persisted
        # Save the changes back
        conn.ResourceService.SaveResource(ldf)
        print "Scale range set to [%d, %d]" % (min, max)
        print "Saved: %s" % (child.ResourceId)		

However, this will not set the scale range at all.

I believe this is because the tags are optional<MinScale></MinScale>
<MaxScale></MaxScale>
Compared with the other functions in the example script, we tried setting
ldf.SubLayer.MinScaleSpecified = True and  ldf.SubLayer.MaxScaleSpecified =
True
But this will cause the python console to report 

AttributeError: ‘DrawingLayerDefintionType’ object has no attributes
MinScaleSpecified

Questions:

1.	How can we make this work?
2.	Where do we find a reference to what “attributes” or
api/methods/properties we can use with this python api for Maestro?

Thanks

Luc




--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Maestro-Python-api-example-script-setScaleRange-for-a-drawingLayer-tp5183707.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list