Parent Directory
|
Revision Log
Links to HEAD: | (view) (annotate) |
Sticky Revision: |
(Layer.TreeInfo): Convert the bounding box to a tuple before using it as arguments to the % operator. This fixes the formatting issue filed in RT#2239 on 2004-01-13 and reported today on thuban-list by Jan Schüngel
* Thuban/Model/layer.py (Layer.LatLongBoundingBox) (Layer.ShapesBoundingBox, RasterLayer.LatLongBoundingBox): Use the new InverseBBox method to determine the unprojected bounding box (Layer.ShapesInRegion): Use the ForwardBBox method to project the bbox. * test/test_layer.py (TestLayer.test_point_layer_with_projection): Removed. (TestLayer.test_arc_layer_with_projection): New. This test is better able to test whether bounding boxes are projected correctly than test_point_layer_with_projection
(Layer.__getattr__): Removed. It was only there for backwards compatibility and all code relying on that should have been updated by now.
Fix some bugs in Thuban and the test suite that were uncovered by changes introduced in Python 2.3: * Thuban/Model/table.py (DBFTable.__init__): Make sure the filename is an absolute name * Thuban/Model/layer.py (RasterLayer.__init__): Make sure the filename is an absolute name * test/test_save.py (SaveSessionTest.testRasterLayer): Use a unique filename to save to and use the correct relative filename in the expected output. (SaveSessionTest.test_dbf_table): Use the correct relative filename in the expected output. * test/test_layer.py (TestLayer.test_raster_layer): Update the test to check whether the filename is absolute.
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/layer.py (Layer.ShapesInRegion): Apply the layer projection to all corners of the bounding box to get a better approximation of the projected bounding box * test/test_layer.py (TestLayer.test_point_layer_with_projection): New. Test coordinate handling of a layer with a projection. Catches the bug fixed in Layer.ShapesInRegion
Remove the unused import of Shape from data. It was only there for interface compatibility but it's not used inside of Thuban and the generic Shape class will go away soon anyway.
* 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.
* Thuban/Model/layer.py (Layer.__init__): Rename classificationField to classificatin_column and init it here so that it can be used in SetClassificationColumn (Layer.GetClassificationColumn, Layer.GetClassificationField): Rename to GetClassificationColumn. (Layer.SetClassificationColumn, Layer.SetClassificationField): Rename to SetClassificationColumn and issue a LAYER_CHANGED message if the column changes. (Layer._classification_changed, Layer.ClassChanged): Rename to _classification_changed. Update the callers. (Layer.SetShapeStore): Further field->column renames. * Thuban/Model/load.py (SessionLoader.start_classification) (SessionLoader.start_clpoint): Updates because of field->column method name changes in the Layer class * Thuban/Model/save.py (SessionSaver.write_classification): Updates because of field->column method name changes in the Layer class * Thuban/UI/classifier.py (Classifier.__init__) (Classifier._OnTry, Classifier._OnRevert): Updates because of field->column method name changes in the Layer class * Thuban/UI/renderer.py (MapRenderer.draw_shape_layer): Updates because of field->column method name changes in the Layer class * Thuban/UI/viewport.py (ViewPort.find_shape_at): Updates because of field->column method name changes in the Layer class * test/test_save.py (SaveSessionTest.testClassifiedLayer) (SaveSessionTest.testClassifiedLayer): Update because of field->column method name changes in the Layer class * test/test_layer.py (SetShapeStoreTests.setUp) (SetShapeStoreTests.test_sanity): Update because of field->column method name changes in the Layer class (TestLayerModification.setUp): Subscribe to LAYER_CHANGED as well (TestLayerModification.test_sanity) (TestLayerModification.test_initial_settings): remove unsued code and rename to test_sanity. (TestLayerModification.test_set_classification): New test for SetClassification and SetClassificationField.
(Layer.Destroy): Unsubscribe from the classification. (Layer.SetShapeStore): Reset the classification first while we still have the old shape store to work with. (Layer.GetClassificationField, Layer.SetClassificationField): New. Method for getting/setting the field to classify on. (Layer.SetClassification): Simplified now that the layer simply has to hold a reference to the classification and not tell the classification who owns it.
(Layer.SetClassification): Switch the classification instance variable to the new class before calling _set_layer otherwise subscribers to a LAYER_CHANGED event will not see any difference.
Fixes RTbug #1971, 1973. (Layer.Destroy): We don't need to call SetClassification anymore to clear out the back reference in the classifcation to the layer. It's better to set it to None using _set_layer, and we won't be creating another clas object too. (Layer.SetClassification): Classification._set_layer is not recursive so remove all the locking variables. Also clean up the code so that it remains unchanged if something fails.
(BaseLayer.HasShapes): New. Overridden by deriving classes to determine if that layer supports shapes. (Layer): Override HasShapes and return true.
Update to the layer interface: Direct access to the table, shapetable, shapefile and filename attributes is now actively deprecated by issuing deprecation warnings for all places where this happens. * Thuban/Model/layer.py (Layer.__getattr__): New. Implement access to the instance variables table, shapetable, shapefile and filename via __getattr__ so that we can issue a deprecation warning. (Layer.SetShapeStore): Don't set the deprecated instance variables any more (Layer.SetShapeStore): Don't use deprecated layer instance variables (Layer.Destroy): No need to explicitly remove the instance variables any more (Layer.GetFieldType, Layer.Shape): Don't use deprecated layer instance variables * Thuban/UI/classgen.py (ClassGenDialog.__init__) (GenUniformPanel._OnRetrieve, GenUniquePanel._OnRetrieve) (GenQuantilesPanel.GetList, GenQuantilesPanel.OnRetrieve): Don't use deprecated layer instance variables * Thuban/UI/classifier.py (Classifier.__init__): Don't use deprecated layer instance variables * Thuban/UI/identifyview.py (IdentifyListCtrl.selected_shape) (IdentifyGridCtrl.selected_shape): Don't set the deprecated layer instance variables * Thuban/UI/tableview.py (LayerTableGrid.select_shapes): Don't use deprecated layer instance variables * Thuban/UI/mainwindow.py (MainWindow.LayerShowTable): Don't use deprecated layer instance variables * Thuban/Model/save.py (SessionSaver.write_layer): Don't use deprecated layer instance variables * Thuban/UI/renderer.py (MapRenderer.draw_shape_layer) (MapRenderer.polygon_render_param): Don't use deprecated layer instance variables * test/runtests.py (main): Turn Thuban's deprecation warnings into errors so that they're cought by the tests * test/test_load.py (TestSingleLayer.test): Don't use deprecated layer instance variables
Import gdal only if it available. (RasterLayer): Handle the case where the gdal library is unavailable. Addresses RTbug #1877.
* Thuban/Model/messages.py (LAYER_SHAPESTORE_REPLACED): New message. * Thuban/Model/layer.py (Layer.SetShapeStore): Send LAYER_SHAPESTORE_REPLACED when the shapestore changes. A LAYER_CHANGED will still be sent if the classification changes. * Thuban/UI/classifier.py (Classifier.__init__): Add the map as parameter so we can subscribe to some of its messages (Classifier.__init__): Subscribe to the map's MAP_LAYERS_REMOVED and the layer's LAYER_SHAPESTORE_REPLACED (Classifier.unsubscribe_messages): New. Unsubscribe from message subscribed to in __init__ (Classifier.map_layers_removed) (Classifier.layer_shapestore_replaced): receivers for the messages subscribed to in __init__. Unsubscribe and close the dialog * Thuban/UI/mainwindow.py (MainWindow.OpenLayerProperties): Pass the map to the Classifier dialog * test/test_layer.py (SetShapeStoreTests): Derive from SubscriberMixin as well so we can test messages (SetShapeStoreTests.setUp): Subscribe to some of the layer's messages (SetShapeStoreTests.tearDown): Clear the messages again (SetShapeStoreTests.test_sanity): Expand the doc-string and check for the modified flag too (SetShapeStoreTests.test_set_shape_store_modified_flag): New test to check whether SetShapeStore sets the modified flag (SetShapeStoreTests.test_set_shape_store_different_field_name) (SetShapeStoreTests.test_set_shape_store_same_field) (SetShapeStoreTests.test_set_shape_store_same_field_different_type): Add tests for the messages. This checks both the new LAYER_SHAPESTORE_REPLACED and the older LAYER_CHANGED
(Layer.Destroy): Set all instance variables to None that have direct or indirect references to shapefiles or dbf files to make sure that they do go away and the files are closed.
* Thuban/Model/layer.py (Layer.SetShapeStore): Set the classification to "None" if the type of the field has changed. * test/test_layer.py (SetShapeStoreTests): New. Class with a few test for the Layer.SetShapeStore method
(Layer.TreeInfo): Fixed a bug (a layer does not necessarily have a filename).
(Layer.TreeInfo): Added filename.
* test/test_layer.py (TestLayer.setUp, TestLayer.tearDown): Provide a better way to destroy the layers (TestLayer.test_base_layer, TestLayer.test_arc_layer) (TestLayer.test_point_layer, TestLayer.test_empty_layer) (TestLayer.test_polygon_layer, TestLayer.test_get_field_type): Use the new way to destroy the layers. (TestLayer.test_derived_store): New. Test for using a layer with a DerivedShapeStore * Thuban/Model/layer.py (Layer.SetShapeStore): Only set the filename if the shape store actually has one.
(RasterLayer.__init__): Test if the filename is a valid image file. Throw IOError otherwise.
(BaseLayer.HasClassification): New. Defaults to False, but can be overridden by subclasses if they support classification. (RasterLayer): New. Defines a new layer that represents an image.
Convert all table users to use the new table interface. This only covers Thuban itself, not GREAT-ER or other applications built on Thuban yet, so the compatibility interface stays in place for the time being but it now issues DeprecationWarnings. Finally, the new Table interface has a new method, HasColumn. * Thuban/Model/table.py (OldTableInterfaceMixin): All methods issue deprecation warnings when they're. The warnings refer to the caller of the method. (OldTableInterfaceMixin.__deprecation_warning): New. Helper method for the deprecation warnings * test/test_table.py: Ignore the deprecation warnings for the old table in the tests in this module. The purpose of the tests is to test the old interface, after all. * test/test_transientdb.py (TestTransientTable.run_iceland_political_tests): Use the constants for the types. Add a test for HasColumn (TestTransientTable.test_transient_joined_table): Adapt to new table interface. Add a test for HasColumn (TestTransientTable.test_transient_table_read_twice): Adapt to new table interface * Thuban/Model/transientdb.py (TransientTableBase.HasColumn) (AutoTransientTable.HasColumn): Implement the new table interface method (AutoTransientTable.ReadRowAsDict, AutoTransientTable.ValueRange) (AutoTransientTable.UniqueValues): Adapt to new table interface * Thuban/Model/layer.py (Layer.SetShapeStore, Layer.GetFieldType): Adapt to new table interface * test/test_layer.py (TestLayer.open_shapefile): Helper method to simplify opening shapefiles a bit easier. (TestLayer.test_arc_layer, TestLayer.test_polygon_layer) (TestLayer.test_point_layer): Use the new helper method (TestLayer.test_get_field_type): New. Test for the GetFieldType method * test/test_dbf_table.py (TestDBFTable.test_has_column): Test for the new table method * test/test_memory_table.py (TestMemoryTable.test_has_column): Test for the new table method HasColumn
(Shape): Since a Shape is immutable only calculate the bounding box once (the first time compute_bbox() is called). (Layer.ShapesBoundingBox): New. Given a list of shape ids, return the bounding box for the shapes in lat/long coordinates.
(Layer.ShapesInRegion): Fix docstring to say that the parameter is a tuple of unprojected points (which is what the callers to this method were assuming). Also, since the points are unprojected we need to projected them.
(Layer.SetShapeStore): Fixed a bug: don't set the Classification to None if the classfication field is None (ie only a DEFAULT).
(BaseLayer.__init__): Change default value of visible from 1 to True. (Layer.__init__): Change default value of visible from 1 to True.
(Layer.TreeInfo): Add an item to the tree for projection information.
(Layer.GetProjection): New. Needed to implement the interface that the ProjFrame dialog expects.
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
Don't import LAYER_LEGEND_CHANGED. (Layer): Update doc-string since LAYER_LEGEND_CHANGED is not used anymore. (Layer.BoundingBox, Layer.GetFieldType, Layer.NumShapes) (Layer.ShapeType, Layer.Shape): No need to call self.open_shapefile since it's always called in __init__
Rename Color.None to Color.Transparent.
(Layer.ClassChanged): Send a LAYER_CHANGED message, not a LAYER_LEGEND_CHANGED message.
(Layer.SetClassification): Generate a LAYER_CHANGED event instead of a LAYER_LEGEND_CHANGED event.
Handle the cyclic references between a layer and its classification better, and be sure to disconnect the classification from the layer when the layer is destroyed so that we don't maintain a cyclic reference that may not be garbage collected.
Added ClassChanged() so that the classification can tell the layer when its data has changed. (Layer.SetClassification): Accepts None as an arguement to remove the current classification and correctly handles adding a new classification.
(SetClassification): prevent recursion between this method and Classification.SetLayer().
(Layer): Add GetFieldType to retreive the kind of data represented by a field.
Fixed name resolution problem.
(Layer): Removed references to fill, stroke, stroke_width attributes. Made the 'classification' attribute private. New methods for setting/getting the classification.
* Thuban/Model/layer.py (Layer): Remove the Set[Fill|Stroke|StrokeWidth]() methods. Code should call the SetDefault*() methods on the layer's classification object. (Layer.__init__): Use the new SetDefault*() methods in the Classification class.
Modified these functions to change the null data in the classification rather than keep these values directly in the Layer class. Menu options to change these values work again.
Added a call to build the tree info for classifications. Commented out unnecessary lines.
Replace user string by _() for i18n.
added classification initializations
(Layer.__init__): Make sure we have an absolute filename.
* Thuban/Model/layer.py (Layer.Destroy): Call the unboundd method with self.
(Layer.Destroy): New. Explicitly close the shapefile and destroy the table.
* Thuban/UI/tree.py (color_string): Removed. No longer used. (SessionTreeCtrl.update_tree, SessionTreeCtrl.add_items): Split update_tree into update_tree and add_items. The tree now uses a more generic way to display the contents of the tree. (SessionTreeCtrl): Add a doc string explaining the TreeInfo method * Thuban/Model/layer.py (Layer.TreeInfo), Thuban/Model/extension.py (Extension.TreeInfo), Thuban/Model/map.py (Map.TreeInfo), Thuban/Model/session.py (Session.TreeInfo): Add TreeInfo methods to implement the new tree view update scheme
* Thuban/Model/layer.py (Layer.open_shapefile): Set bbox to None when the shapefile is empty. (Layer.BoundingBox, Layer.LatLongBoundingBox): Both methods may now return None for empty shapefiles. Update doc-strings.
* Thuban/Model/layer.py (Layer.open_shapefile): Choose a better maximum depth for the tree than shapelib does by default.
* Thuban/Model/layer.py (Layer.ShapesInRegion): Remove some debug prints.
* Thuban/Model/layer.py (Layer.__init__): New instance variable shapetree to hold the shapelib quadtree for the shapefile (Layer.open_shapefile): Create the quad tree. (Layer.ShapesInRegion): New method to return the ids of shapes in a given region using the quad tree.
* Thuban/Model/layer.py (Layer.Shape): list append only takes one argument (python <= 1.5.2 erroneously accepted multiuple arguments)
* Thuban/Model/layer.py (Layer.__init__): New parameter and instance variable stroke_width (Layer.SetStrokeWidth): Set the stroke_width.
Open the shapefile immediately. This will cause an exception in case the file can't be opened and we can display an appropriate message.
import all the source files
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 |