Introduce FileShapeStore

Bernhard Herzog bh at intevation.de
Fri Apr 22 21:06:21 CEST 2005


Jan-Oliver Wagner <jan at intevation.de> writes:

> +class FileShapeStore:
> +
> +    """The base class to derive any file-based ShapeStore from.
> +
> +    This class contains all information that is needed by a
> +    loader routine to actually load the shapestore.
> +    This essentially means that the class contains all required information
> +    to save the shapestore specification (i.e. in a .thuban file).
> +    """
> +
> +    def __init__(self, filename, filetype, layername = None):
> +        """Initialize the base class with main parameters.
> +
> +        filename  -- the source filename.
> +                     This filename will be converted to an absolute filename.
> +                     The filename will be interpreted relative to that anyway,

Relative to what?

> +                     but when saving a session we need to compare absolute paths
> +                     and it's usually safer to always work with absolute paths.
> +        filetype  -- The type of the filename.
> +                     Known and used types are: "shapefile"

AFAICT the filetype will be the same for all instances of a class, so I
guess it should be a class attribute that has to be defined by the
derived classes.  There's no need to pass it as a parameter to the
constructor.


> +        layername -- a string representing a layer within the file shape store.
> +                     Some file formats support to contain several layers, or
> +                     at least the ogr library says so.
> +                     For those filetypes who don't, the layername can be ignored
> +                     and by default it is None.

Would it make sense to call it something other than layername?  We
already have a layer in thuban and it has a somewhat different meaning.


> +    def layer_name(self):

This should be spelled LayerName to follow the naming scheme of the
other public methods. (assuming the method is to be public).

> @@ -148,22 +225,10 @@ class ShapefileStore:
>          self.shapetree = shptree.SHPTree(self.shapefile.cobject(), 2,
>                                           maxdepth)
>  
> -    def Table(self):
> -        """Return the table containing the attribute data"""
> -        return self.table
> -
[...]
>  
> @@ -186,6 +251,10 @@ class ShapefileStore:
>          """
>          return ()
>  
> +    def Table(self):
> +        """Return the table containing the attribute data."""
> +        return self._table
> +

I think we should avoid moving the methods around unnecessarily, if
possible.  The same applies to BoundingBox.

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                           http://skencil.org/
Thuban                                  http://thuban.intevation.org/




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)