Parent Directory
|
Revision Log
Sticky Revision: |
made a copy
Various small fixes in doc-strings. (FileShapeStore): New class. (ShapefileStore): Derive from FileShapeStore. (ShapefileStore.__init__): Call __init__ of FileShapeStore, rename self.table to self._table, initialize self._bbox (ShapefileStore._open_shapefile): Use self._bbox instead of self.bbox and self.FileName() instead of self.filename. (ShapefileStore.Table): Use self._table instead of self.table. (ShapefileStore.FileName): Removed (moved to FileShapeStore). (ShapefileStore.BoundingBox): Use self._bbox instead of self.bbox.
(ShapefileStore._open_shapefile) (ShapefileStore.__init__): Factor opening the shapefile into a separate method (the new _open_shapefile). This makes the code a bit more readable but the real reason is that it makes some evil hacks easier. :-)
(ShapefileStore.ShapesInRegion): Bind some globals to locals so that it's a bit faster
Add very basic postgis database support and the corresponding test cases. The test cases require a PostgreSQL + postgis installation but no existing database. The database will be created automatically by the test cases * test/README: Add note about skipped tests and the requirements of the postgis tests. * Thuban/Model/postgisdb.py: New. Basic postgis database support. * test/test_postgis_db.py: New. Test cases for the postgis support. * Thuban/Model/wellknowntext.py: New. Parser for well-known-text format * test/test_wellknowntext.py: New. Test cases for the wellknowntext parser * test/postgissupport.py: New. Support module for tests involving a postgis database. * test/support.py (execute_as_testsuite): Shut down the postmaster if it's still running after the tests * Thuban/Model/data.py (RAW_WKT): New constant for raw data in well known text format
Change the way shapes are returned by a shape store. The ShapesInRegion method returns an iterator over actual shape objects instead of a list of shape ids. * Thuban/Model/data.py (ShapefileShape.ShapeID): New. Return shape id. (ShapefileStore.ShapesInRegion): Return an iterator over the shapes which yields shape objects instead of returning a list of shape ids (ShapefileStore.AllShapes): New. Return an iterator over all shapes in the shape store (DerivedShapeStore.AllShapes): New. Like in ShapefileStore * Thuban/Model/layer.py (Layer.ShapesInRegion): Update doc-string. * Thuban/UI/baserenderer.py (BaseRenderer.layer_ids, BaseRenderer.layer_shapes): Rename to layer_shapes and make it return an iterator containg shapes instead of a list of ids. (BaseRenderer.draw_shape_layer): Update doc-string; Adapt to layer_shapes() change * Thuban/UI/renderer.py (ScreenRenderer.layer_ids) (ScreenRenderer.layer_shapes): Rename as in BaseRenderer * Thuban/UI/viewport.py (ViewPort._find_shape_in_layer): Adapt to changes in the ShapesInRegion return value. (ViewPort._get_hit_tester): Remove commented out code * test/mockgeo.py (SimpleShapeStore.ShapesInRegion): Adapt to the new return value. (SimpleShapeStore.AllShapes): New. Implement this method too. * test/test_layer.py (TestLayer.test_arc_layer) (TestLayer.test_polygon_layer, TestLayer.test_point_layer) (TestLayer.test_point_layer_with_projection) (TestLayer.test_derived_store): Adapt to changes in the ShapesInRegion return value. * test/test_shapefilestore.py (TestShapefileStoreArc.test_shapes_in_region) (TestShapefileStorePolygon.test_shapes_in_region) (TestShapefileStorePoint.test_shapes_in_region): Adapt to changes in the ShapesInRegion return value. (TestShapefileStorePoint.test_all_shapes) (TestShapefileStoreArc.test_shape_shapeid): New tests for the new methods * test/test_derivedshapestore.py (TestDerivedShapeStore.test_shapes_in_region): Adapt to changes in the ShapesInRegion return value. (TestDerivedShapeStore.test_all_shapes) (TestDerivedShapeStore.test_shape_shapeid): New tests for the new methods
* Thuban/Model/data.py (DerivedShapeStore.RawShapeFormat): New. Simply delegates to the original shapestore. * test/test_derivedshapestore.py (TestDerivedShapeStore.test_raw_format): New. Test case for DerivedShapeStore.RawShapeFormat
update ChangeLog
* Thuban/Model/data.py (ShapefileStore.Shape): For consistency, a Shape object will always have the coordinates as a list of list of coordinate pairs (tuples). (Shape.compute_bbox): Adapt to new representation. * Thuban/UI/viewport.py (ViewPort.find_shape_at) (ViewPort.LabelShapeAt): Adapt to new coordinate representation in Shape objects. * test/test_shapefilestore.py (ShapefileStoreTests.assertFloatTuplesEqual) (ShapefileStoreTests.assertPointListEquals): Rename to assertPointListEquals and change purpose to checking equality of the lists returned by Shape.Points(). (TestShapefileStoreArc.test_shape) (TestShapefileStorePolygon.test_shape) (TestShapefileStorePoint.test_shape): Use the new assertPointListEquals instead of assertFloatTuplesEqual * test/test_layer.py (TestLayer.assertFloatTuplesEqual) (TestLayer.assertPointListEquals): Rename to assertPointListEquals and change purpose to checking equality of the lists returned by Shape.Points(). (TestLayer.test_arc_layer, TestLayer.test_arc_layer) (TestLayer.test_polygon_layer, TestLayer.test_point_layer) (TestLayer.test_derived_store): Use the new assertPointListEquals instead of assertFloatTuplesEqual * test/test_derivedshapestore.py (TestDerivedShapeStore.assertFloatTuplesEqual) (TestDerivedShapeStore.assertPointListEquals): Rename to assertPointListEquals and change purpose to checking equality of the lists returned by Shape.Points(). (TestDerivedShapeStore.test_shape): Use the new assertPointListEquals instead of assertFloatTuplesEqual
* Thuban/Model/data.py (SHAPETYPE_POLYGON, SHAPETYPE_ARC) (SHAPETYPE_POINT, Shape): Move these constants and classes from layer.py to data.py (ShapefileStore.__init__): More Initialization for the new methods and functionality. (ShapefileStore.ShapeType, ShapefileStore.NumShapes) (ShapefileStore.BoundingBox, ShapefileStore.ShapesInRegion) (ShapefileStore.Shape): New methods that were formerly implemented in the layer. (DerivedShapeStore.Shape, DerivedShapeStore.ShapesInRegion) (DerivedShapeStore.ShapeType, DerivedShapeStore.NumShapes) (DerivedShapeStore.BoundingBox): New. DerivedShapeStore equivalents of the new shape methods. These versions are simply delegated to the original shapstore. * Thuban/Model/layer.py (SHAPETYPE_POLYGON, SHAPETYPE_ARC) (SHAPETYPE_POINT, Shape): Removed. They're now in data.py (Layer.SetShapeStore): Removed the initializatin of instance variables that were needed for the stuff that's now in ShapefileStore (Layer.BoundingBox, Layer.NumShapes, Layer.ShapeType) (Layer.Shape, Layer.ShapesInRegion): Simply delegate to the shapestore.
Remove the now unused import of warnings
(SimpleStore): Removed. This class has been deprecated since before the 0.8 release and isn't used in Thuban itself anymore.
(DerivedShapeStore.__init__): Raise an exception if the number of shapes is different from the number of rows in the table. Address RTbug #1933.
* Thuban/UI/mainwindow.py (MainWindow.delegated_messages): Also delegate SelectedLayer. (MainWindow.LayerUnjoinTable): Implement. (_can_unjoin): New. Helper function for the sensitivity of the layer/unjoin command. * Thuban/Model/data.py (ShapefileStore.OrigShapeStore) (DerivedShapeStore.OrigShapeStore): New. Return the original shapestore. Used to figure out how to unjoin. (DerivedShapeStore.Shapefile): Fix a typo.
Implement a way to discover dependencies between tables and shapestores. * Thuban/Model/transientdb.py (TransientTableBase.Dependencies) (TransientJoinedTable.Dependencies) (AutoTransientTable.SimpleQuery): New. Implement the dependencies interface (TransientJoinedTable.__init__): Keep tack of the original table objects in addition to the corresponding transient tables. * Thuban/Model/table.py (DBFTable.Dependencies) (MemoryTable.Dependencies): New. Implement the dependencies interface * Thuban/Model/data.py (ShapeTable): New. Helper class for ShapefileStore (ShapefileStore.__init__): Use ShapeTable instead of AutoTransientTable (ShapefileStore.Table, ShapefileStore.Shapefile): Add doc-strings (ShapefileStore.FileName, ShapefileStore.FileType): New. Accessor methods for filename and type (ShapefileStore.Dependencies): New. Implement the dependencies interface (DerivedShapeStore): New class to replace SimpleStore. The main difference to SimpleStore is that it depends not on a shapefile but another shapestore which expresses the dependencies a bit better (SimpleStore.__init__): Add deprecation warning. * test/test_dbf_table.py (TestDBFTable.test_dependencies): New. Test for the Dependencies method. * test/test_memory_table.py (TestMemoryTable.test_dependencies): New. Test for the Dependencies method. * test/test_transientdb.py (TestTransientTable.test_auto_transient_table_dependencies): New. Test for the Dependencies method. (TestTransientTable.test_transient_joined_table): Add test for the Dependencies method. * test/test_session.py (TestSessionSimple.setUp) (TestSessionSimple.tearDown): New. Implement a better way to destroy the sessions. (TestSessionSimple.test_initial_state) (TestSessionSimple.test_add_table): Bind session to self.session so that it's destroyed by tearDown (TestSessionSimple.test_open_shapefile): New. Test for OpenShapefile and the object it returns
Next step of table implementation. Introduce a transient database using SQLite that some of the data is copied to on demand. This allows us to do joins and other operations that require an index for good performance with reasonable efficiency. Thuban now needs SQLite 2.8.0 and pysqlite 0.4.1. Older versions may work but I haven't tested that. * Thuban/Model/transientdb.py: New. Transient database implementation. * test/test_transientdb.py: New. Tests for the transient DB classes. * Thuban/Model/session.py (AutoRemoveFile, AutoRemoveDir): New classes to help automatically remove temporary files and directories. (Session.__init__): New instance variables temp_dir for the temporary directory and transient_db for the SQLite database (Session.temp_directory): New. Create a temporary directory if not yet done and return its name. Use AutoRemoveDir to have it automatically deleted (Session.TransientDB): Instantiate the transient database if not done yet and return it. * Thuban/Model/data.py (ShapefileStore.__init__): Use an AutoTransientTable so that data is copied to the transient DB on demand. (SimpleStore): New class that simply combines a table and a shapefile * Thuban/Model/table.py (Table, DBFTable): Rename Table into DBFTable and update its doc-string to reflect the fact that this is only the table interface to a DBF file. Table is now an alias for DBFTable for temporary backwards compatibility. * Thuban/UI/application.py (ThubanApplication.OnExit): Make sure the last reference to the session goes away so that the temporary files are removed properly. * test/test_load.py (LoadSessionTest.tearDown): Remove the reference to the session to make sure the temporary files are removed.
First step towards table management. Introduce a simple data abstraction so that we replace the data a layer uses more easily in the next step. * Thuban/Model/data.py: New file with a simple data abstraction that bundles shapefile and dbffile into one object. * Thuban/Model/session.py (Session.OpenShapefile): New method to open shapefiles and return a shape store object * Thuban/Model/layer.py (Layer.__init__): Pass the data as a store object instead of a shapefile filename. This introduces a new instance variable store holding the datastore. For intermediate backwards compatibility keep the old instance variables. (open_shapefile): Removed. No longer needed with the shape store. (Layer.SetShapeStore, Layer.ShapeStore): New methods to set and get the shape store used by a layer. (Layer.Destroy): No need to explicitly destroy the shapefile or table anymore. * Thuban/UI/mainwindow.py (MainWindow.AddLayer) (MainWindow.AddLayer): Use the session's OpenShapefile method to open shapefiles * Thuban/Model/load.py (ProcessSession.start_layer): Use the session's OpenShapefile method to open shapefiles * test/test_classification.py (TestClassification.test_classification): Use the session's OpenShapefile method to open shapefiles and build the filename in a more platform independed way * test/test_layer.py (TestLayer.setUp, TestLayer.tearDown): Implement to have a session to use in the tests (TestLayer.test_arc_layer, TestLayer.test_polygon_layer) (TestLayer.test_point_layer, TestLayer.test_empty_layer): Use the session's OpenShapefile method to open shapefiles (TestLayerLegend.setUp): Instantiate a session so that we can use it to open shapefiles. (TestLayerLegend.tearDown): Make sure that all references to layers and session are removed otherwise we may get a resource leak * test/test_map.py (TestMapAddLayer.test_add_layer) (TestMapWithContents.setUp): Instantiate a session so that we can use it to open shapefiles. (TestMapWithContents.tearDown): Make sure that all references to layers, maps and sessions are removed otherwise we may get a resource leak ("__main__"): use support.run_tests() so that more info about uncollected garbage is printed * test/test_save.py (SaveSessionTest.testSingleLayer): Use the session's OpenShapefile method to open shapefiles ("__main__"): use support.run_tests() so that more info about uncollected garbage is printed * test/test_selection.py (TestSelection.tearDown): Make sure that all references to the session and the selection are removed otherwise we may get a resource leak (TestSelection.get_layer): Instantiate a session so that we can use it to open shapefiles. ("__main__"): use support.run_tests() so that more info about uncollected garbage is printed * test/test_session.py (TestSessionBase.tearDown) (TestSessionWithContent.tearDown): Make sure that all references to the session and layers are removed otherwise we may get a resource leak (TestSessionWithContent.setUp): Use the session's OpenShapefile method to open shapefiles
This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, enter a numeric revision.
[email protected] | ViewVC Help |
Powered by ViewVC 1.1.26 |