Example #1
0
    def get_feature_info(self, wherex, wherey, layers, callback, format, feature_count, srs, filter):
        if type(srs) is int:
            kind='srid'
        elif srs.upper().startswith('EPSG'):
            kind=None
        elif srs.startswith('-') or srs.startswith('+'):
            kind='proj'
        else:
            kind='wkt'

        s_srs = create_spatialref(srs, srs_format=kind)
        t_srs = self.dataset.GetSpatialRef()
        crx = osr.CoordinateTransformation(s_srs, t_srs)
        wherex, wherey, _0 = crx.TransformPoint(wherex, wherey, 0)

        if not filter:
            for layer in layers:
                l = self.dataset.GetLayerByName(layer)
                l.ResetReading()
                l.SetSpatialFilterRect(wherex, wherey, wherex+0.0001, wherey+0.0001)
                return [f for f in l]
        else:
            for layer in layers:
                l = self.dataset.GetLayerByName(layer)
                l.ResetReading()
                l.SetSpatialFilterRect(wherex, wherey, wherex+0.0001, wherey+0.0001)
                return [f for f in l] # TODO apply filter.
Example #2
0
    def get_feature_info(self, wherex, wherey, layers, callback, format,
                         feature_count, srs, filter):
        if type(srs) is int:
            kind = 'srid'
        elif srs.upper().startswith('EPSG'):
            kind = None
        elif srs.startswith('-') or srs.startswith('+'):
            kind = 'proj'
        else:
            kind = 'wkt'

        s_srs = create_spatialref(srs, srs_format=kind)
        t_srs = self.dataset.GetSpatialRef()
        crx = osr.CoordinateTransformation(s_srs, t_srs)
        wherex, wherey, _0 = crx.TransformPoint(wherex, wherey, 0)

        if not filter:
            for layer in layers:
                l = self.dataset.GetLayerByName(layer)
                l.ResetReading()
                l.SetSpatialFilterRect(wherex, wherey, wherex + 0.0001,
                                       wherey + 0.0001)
                return [f for f in l]
        else:
            for layer in layers:
                l = self.dataset.GetLayerByName(layer)
                l.ResetReading()
                l.SetSpatialFilterRect(wherex, wherey, wherex + 0.0001,
                                       wherey + 0.0001)
                return [f for f in l]  # TODO apply filter.
Example #3
0
    def get_feature_info(self, wherex, wherey, layers, callback, format,
                         feature_count, srs, filter):
        if type(srs) is int:
            kind = 'srid'
        elif srs.upper().startswith('EPSG'):
            kind = None
        elif srs.startswith('-') or srs.startswith('+'):
            kind = 'proj'
        else:
            kind = 'wkt'

        s_srs = create_spatialref(srs, srs_format=kind)
        t_srs = self.cls.srs
        crx = osr.CoordinateTransformation(s_srs, t_srs)
        wherex, wherey, _0 = crx.TransformPoint(wherex, wherey, 0)

        if not filter:
            return [
                self.cls.objects.filter({
                    layer + "__contains":
                    g.Point(wherex, wherey)
                }).limit(feature_count).values() for layer in layers
            ]
        else:
            return [
                self.cls.objects.filter({
                    layer + "__contains":
                    g.Point(wherex, wherey)
                }).filter(**filter).limit(feature_count).values()
                for layer in layers
            ]
Example #4
0
    def get_feature_info(self, wherex, wherey, layers, callback, format, feature_count, srs, filter):
        if type(srs) is int:
            kind='srid'
        elif srs.upper().startswith('EPSG'):
            kind=None
        elif srs.startswith('-') or srs.startswith('+'):
            kind='proj'
        else:
            kind='wkt'

        s_srs = create_spatialref(srs, srs_format=kind)
        t_srs = self.cls.srs
        crx = osr.CoordinateTransformation(s_srs, t_srs)
        wherex, wherey, _0 = crx.TransformPoint(wherex, wherey, 0)

        if not filter:
            return [self.cls.objects.filter({ layer + "__contains" : g.Point(wherex, wherey) }).limit(feature_count).values() for layer in layers]
        else:
            return [self.cls.objects.filter({ layer + "__contains" : g.Point(wherex, wherey) }).filter(**filter).limit(feature_count).values() for layer in layers]
Example #5
0
File: wms.py Project: gijs/ga_ows
    def get_feature_info(self, wherex, wherey, srs, query_layers, info_format, feature_count, exceptions, *args, **kwargs):
        if type(srs) is int:
            kind='srid'
        elif srs.upper().startswith('EPSG'):
            kind=None
        elif srs.startswith('-') or srs.startswith('+'):
            kind='proj'
        else:
            kind='wkt'

        s_srs = create_spatialref(srs, srs_format=kind)
        t_srs = self.cls.srs
        crx = osr.CoordinateTransformation(s_srs, t_srs)
        wherex, wherey, _0 = crx.TransformPoint(wherex, wherey, 0)

        if info_format == 'application/json':
            return HttpResponse(serializers.serialize('json', [self.cls.objects.filter({ layer + "__contains" : g.Point(wherex, wherey) }).limit(feature_count) for layer in query_layers]),  mimetype='application/json')
        elif info_format == 'application/jsonp':
            return HttpResponse(kwargs['callback'] + '(' + serializers.serialize('json', [self.cls.objects.filter({ layer + "__contains" : g.Point(wherex, wherey) }).limit(feature_count) for layer in query_layers]) + ')',  mimetype='application/jsonp')
Example #6
0
def layer_description(**kwargs):
    validate = _dict_from_valid(name='', title='', srs='', minx=-180.0, miny=-90.0, maxx=180.0, maxy=90.0, styles=[])
    cfg = validate(kwargs)

    if type(cfg['srs']) is int:
        kind='srid'
    elif cfg['srs'].upper().startswith('EPSG'):
        kind=None
    elif cfg['srs'].startswith('-') or cfg['srs'].startswith('+'):
        kind='proj'
    else:
        kind='wkt'

    s_srs = create_spatialref(cfg['srs'], srs_format=kind)
    t_srs = osr.SpatialReference()
    t_srs.ImportFromEPSG(4326)

    t = osr.CoordinateTransformation(s_srs, t_srs)
    cfg['ll_minx'], cfg['ll_miny'], _0 = t.TransformPoint(cfg['minx'], cfg['miny'])
    cfg['ll_maxx'], cfg['ll_maxy'], _0 = t.TransformPoint(cfg['maxx'], cfg['maxy'])
    return cfg