Пример #1
0
    def _get_unique_mapfile(self, classification):
        layerobj = self._get_layer_stub()
        attribute = classification['attribute']
        column = self._get_column(attribute)
        if column is None:
            raise ValueError("column %s not found in datasource %s" %
                             (attribute, self.name))
        values = self.get_distinct_values(attribute)
        layerobj.classitem = attribute
        theme = self._get_theme(classification, len(values))
        for value in values:
            color = theme.pop(0)
            classobj = mapscript.classObj()
            layerobj.insertClass(classobj)
            styleobj = self._get_default_style()
            styleobj.color.setRGB(color[0], color[1], color[2])
            classobj.insertStyle(styleobj)
            if column['type'] == 'numeric':
                classobj.name = '%s' % (value)
                classobj.setExpression('([%s]==%s)' % (attribute, value))
            else:
                classobj.name = '%s' % (value)
                classobj.setExpression('("[%s]"=="%s")' %
                                       (attribute.encode('utf8'), value))

        return mapserializer.layerobj_to_dict(layerobj, None)
Пример #2
0
 def get_mapfile(self, classification=None):
     layerobj = mapscript.layerObj()
     layerobj.status = mapscript.MS_ON
     layerobj.type = mapscript.MS_LAYER_RASTER
     layerobj.name = self.name
     layerobj.data = self.gdal_source.GetDescription()
     projection = self.get_proj4()
     if projection is not None:
         layerobj.setProjection(projection)
     return mapserializer.layerobj_to_dict(layerobj, None)
Пример #3
0
 def get_mapfile(self,classification = None):
     layerobj = mapscript.layerObj()
     layerobj.status = mapscript.MS_ON
     layerobj.type = mapscript.MS_LAYER_RASTER
     layerobj.name = self.name
     layerobj.data = self.gdal_source.GetDescription()
     projection = self.get_proj4()
     if projection is not None:
         layerobj.setProjection(projection)
     return mapserializer.layerobj_to_dict(layerobj,None)
Пример #4
0
    def _get_default_mapfile_excerpt(self):
        """ Given an OGR string, an OGR connection and an OGR layer, create and
        return a representation of a MapFile LAYER block. """

        layerobj = self._get_layer_stub()
        classobj = mapscript.classObj()
        layerobj.insertClass(classobj)
        styleobj = self._get_default_style()
        classobj.insertStyle(styleobj)

        return mapserializer.layerobj_to_dict(layerobj, None)
Пример #5
0
 def _get_default_mapfile_excerpt(self):
     """ Given an OGR string, an OGR connection and an OGR layer, create and
     return a representation of a MapFile LAYER block. """
         
     layerobj = self._get_layer_stub()
     classobj = mapscript.classObj() 
     layerobj.insertClass(classobj)
     styleobj = self._get_default_style()
     classobj.insertStyle(styleobj)
     
     return mapserializer.layerobj_to_dict(layerobj,None)
Пример #6
0
 def _get_quantile_mapfile(self,classification):
     layerobj = self._get_layer_stub()
     intervals = int(classification['intervals'])
     attribute = classification['attribute']
     bounds = self._get_classification_bounds(attribute, intervals)
     theme = self._get_theme(classification, len(bounds)+1)
     for i in range(0, len(bounds)+1):
         color = theme[i]
         classobj = mapscript.classObj() 
         layerobj.insertClass(classobj)
         if i<len(bounds):
             classobj.setExpression('([%s]<%s)'%(attribute, _nice_float(bounds[i])))
             classobj.name = '%s < %s'%(attribute, _nice_float(bounds[i]))
         else:
             classobj.name = '%s >= %s'%(attribute, _nice_float(bounds[i-1]))
         styleobj = mapscript.styleObj()
         styleobj.color.setRGB(color[0],color[1],color[2])
         classobj.insertStyle(styleobj)
     return mapserializer.layerobj_to_dict(layerobj,None)
Пример #7
0
 def _get_quantile_mapfile(self, classification):
     layerobj = self._get_layer_stub()
     intervals = int(classification['intervals'])
     attribute = classification['attribute']
     bounds = self._get_classification_bounds(attribute, intervals)
     theme = self._get_theme(classification, len(bounds) + 1)
     for i in range(0, len(bounds) + 1):
         color = theme[i]
         classobj = mapscript.classObj()
         layerobj.insertClass(classobj)
         if i < len(bounds):
             classobj.setExpression('([%s]<%s)' %
                                    (attribute, _nice_float(bounds[i])))
             classobj.name = '%s < %s' % (attribute, _nice_float(bounds[i]))
         else:
             classobj.name = '%s >= %s' % (attribute,
                                           _nice_float(bounds[i - 1]))
         styleobj = mapscript.styleObj()
         styleobj.color.setRGB(color[0], color[1], color[2])
         classobj.insertStyle(styleobj)
     return mapserializer.layerobj_to_dict(layerobj, None)
Пример #8
0
    def _get_unique_mapfile(self,classification):
        layerobj = self._get_layer_stub()
        attribute = classification['attribute']
        column = self._get_column(attribute)
        if column is None:
            raise ValueError("column %s not found in datasource %s"%(attribute,self.name))
        values = self.get_distinct_values(attribute)
        layerobj.classitem = attribute
        theme = self._get_theme(classification, len(values))
        for value in values:
            color = theme.pop(0)
            classobj = mapscript.classObj() 
            layerobj.insertClass(classobj)
            styleobj = self._get_default_style()
            styleobj.color.setRGB(color[0],color[1],color[2])
            classobj.insertStyle(styleobj)
            if column['type'] == 'numeric':
                classobj.name = '%s'%(value)
                classobj.setExpression('([%s]==%s)'%(attribute,value))
            else:
                classobj.name = '%s'%(value)
                classobj.setExpression('("[%s]"=="%s")'%(attribute.encode('utf8'),value))

        return mapserializer.layerobj_to_dict(layerobj,None)