Esempio n. 1
0
    if not self._info:
      if isinstance(layer, (str,unicode)):
        cat = self.catalog
        ft = cat._catalog.getFeatureTypeByDataStore(self.store._info, layer)

        if not ft:
          b = cat.builder()
          b.setStore(store._info)
          ft = b.buildFeatureType(Name(layer))

        self._info = ft
      else:
        raise Exception('Unable to create layer from %s' % str(layer))

  @lazy
  def data(self):
    """
    The data backing the layer as a geoscript layer.
    
    >>> l = Layer('sf:archsites')
    >>> l.data.schema
    archsites [the_geom: Point, cat: long, str1: str]
    >>> l.data.count()
    25
    """
    fs = self._info.getFeatureSource(None, None)
    return GeoScriptLayer(workspace=self.store.data, source=fs)

Layer = info(Layer)
Esempio n. 2
0
        if ns.prefix == None:
            ns.prefix = self.name

        if ns.id:
            cat.save(ns)
        else:
            cat.add(ns)

    def __getitem__(self, key):
        store = self.catalog._catalog.getDataStoreByName(self._info, key)
        if store:
            return Store(store, self, self.catalog)

        raise KeyError('No such store %s' % key)

    def __setitem__(self, key, val):
        self.add(key, val)

    def __iter__(self):
        return self.keys().__iter__()

    def iterkeys(self):
        return self.keys().__iter__()

    def iteritems(self):
        for st in self.keys():
            yield (st, self.get(st))


Workspace = info(Workspace)
Esempio n. 3
0
     ns = self._nsinfo
     if ns.prefix == None:
       ns.prefix = self.name

     if ns.id:
       cat.save(ns)
     else:
       cat.add(ns)

  def __getitem__(self, key):
     store = self.catalog._catalog.getDataStoreByName(self._info, key)
     if store:
       return Store(store, self, self.catalog)

     raise KeyError('No such store %s' % key)

  def __setitem__(self, key, val):
    self.add(key, val)

  def __iter__(self):
    return self.keys().__iter__()    

  def iterkeys(self):
    return self.keys().__iter__()

  def iteritems(self):
    for st in self.keys():
      yield (st, self.get(st))

Workspace = info(Workspace)
Esempio n. 4
0
  """
    def __init__(self):
        try:
            from org.geoserver.platform import GeoServerExtensions
        except ImportError:
            pass
        else:
            self._geoserver = GeoServerExtensions.bean('geoServer')

    def getcatalog(self):
        from geoserver.catalog import Catalog
        return Catalog()

    catalog = property(
        getcatalog, None, None,
        'The GeoServer :class:`Catalog <geoserver.catalog.Catalog>`')

    def getconfig(self):
        return Config(self._geoserver.getGlobal(), self)

    config = property(getconfig, None, None, 'The GeoServer configuration.')


class Config(object):
    def __init__(self, config, geoserver):
        self.geoserver = geoserver
        self._info = config


Config = util.info(Config)
Esempio n. 5
0
     
     >>> shapes = Store('taz_shapes', 'topp')
     >>> shapes.data.layers()
     ['tasmania_state_boundaries', 'tasmania_water_bodies', 'tasmania_roads', 'tasmania_cities']
     """
        return GeoScriptWorkspace(ds=self._info.getDataStore(None))

    def keys(self):
        featureTypes = self.catalog._catalog.getFeatureTypesByStore(self._info)
        return [ft.getName() for ft in featureTypes]

    def __getitem__(self, key):
        layer = self.catalog._catalog.getFeatureTypeByStore(self._info, key)
        if layer:
            return Layer(layer, self)

        raise KeyError('No such layer %s' % (key))

    def __iter__(self):
        return self.layers().__iter__()

    def iterkeys(self):
        return self.layers().__iter__()

    def iteritems(self):
        for l in self.layers():
            return (l, self.__getitem__(l))


Store = info(Store)
Esempio n. 6
0
     The data backing the store as a geoscript workspace.
     
     >>> shapes = Store('taz_shapes', 'topp')
     >>> shapes.data.layers()
     ['tasmania_state_boundaries', 'tasmania_water_bodies', 'tasmania_roads', 'tasmania_cities']
     """
     return GeoScriptWorkspace(ds=self._info.getDataStore(None))

   def keys(self):
     featureTypes = self.catalog._catalog.getFeatureTypesByStore(self._info)
     return [ft.getName() for ft in featureTypes]

   def __getitem__(self, key):
     layer = self.catalog._catalog.getFeatureTypeByStore(self._info, key)
     if layer:
       return Layer(layer, self)

     raise KeyError('No such layer %s' % (key))

   def __iter__(self):
     return self.layers().__iter__()

   def iterkeys(self):
     return self.layers().__iter__()

   def iteritems(self):
     for l in self.layers():
       return (l, self.__getitem__(l))

Store = info(Store)