Parent Directory
|
Revision Log
Sticky Revision: |
made a copy
* Thuban/Model/postgisdb.py (PostGISConnection.connect): Set the connection to autoconnect. Fixes RT#3148. * test/test_postgis_db.py (TestPostGISSpecialCases.test_simple_error_handling): New test that attempts to reproduce RT#3148.
Add support for PostGIS tables with LINESTRING geomentries. Fixes RT#2299 * Thuban/Model/postgisdb.py (shapetype_map): Add LINESTRING * test/postgissupport.py (PostgreSQLServer.get_default_static_data_db): Rename the "roads" table to "roads-multi" because it now uses MULTILINESTRING geometries and introduce a new "roads" table that uses LINESTRING (coords_to_multilinestring): Make the doc string more precise (coords_to_linestring): New. Create a LINESTRING WKT representatin (wkt_converter): Add coords_to_linestring (upload_shapefile): Rephrase the doc-string a bit. * test/test_postgis_db.py (TestPostGISShapestoreArc) (LineStringTests) (TestPostGISShapestoreLineString) (TestPostGISShapestoreMultiLineString): Split TestPostGISShapestoreArc into a base class LineStringTests and two derived classes TestPostGISShapestoreLineString for LINESTRING geometries and TestPostGISShapestoreMultiLineString for MULTILINESTRING geometries. Most test methods are in the base class with the exception of tests that explicitly check the raw format.
Support views in addition to normal tables in the postgis shapestore * Thuban/Model/postgisdb.py (PostGISShapeStore._fetch_table_information): Add a fallback for the case where the table name is not in the geometry_columns table. This is usually the case for views. Also, set self.shapestore here. (PostGISShapeStore.ShapeType): No need to query the database all the time. The shape type is now determined in _fetch_table_information * test/postgissupport.py (PostgreSQLServer.new_postgis_db) (PostgreSQLServer.get_static_data_db, PostGISDatabase.__init__): New parameter to specify views. (PostGISDatabase.has_data): Also compare the views. New views parameter (PostGISDatabase.initdb): Create the views. (PostgreSQLServer.get_default_static_data_db): Add the v_landmarks view * test/test_postgis_db.py (TestPostGISShapestorePointFromViews): New. Test a PostGISShapeStore with a view (TestPostGISShapestorePointOIDAsGIDColumn.setUp): Pass the name of the geometry_column explicitly to test whether that works
* Thuban/UI/dbdialog.py (ChooseDBTableDialog.__init__): Rework how the dialog is constructed. Add combo boxes to select id and geometry column. Rename some instance variables. (ChooseDBTableDialog.GetTable): Return id and geometry column names (ChooseDBTableDialog.OnTableSelect): New. Event handler for selections in the table list * Thuban/UI/mainwindow.py (MainWindow.AddDBLayer): Use id_column and geometry_column * Thuban/Model/session.py (Session.OpenDBShapeStore): Add the new parameters for id_column and geometry column of PostGISShapeStore here as well. * Thuban/Model/postgisdb.py (type_map): Add ROWID psycog type. (_raw_type_map): New. Map raw PostgreSQL type ints to thuban types (PostGISConnection.GeometryTables): Use a better query to determine which relations in the database might be usable for shapestores. Now supports views as well but is more PostgreSQL specific (PostGISConnection.table_columns): New. Somewhat experimental method to let the db dialogs provide lists of columns to users so that they can select id and geometry columns. (PostGISTable.__init__): The default value of the id_column parameter is now None it still means "gid" effectively, though. (PostGISTable.IDColumn): New introspection method to return a column object for the id column (PostGISShapeStore.GeometryColumn): New introspection method to return a column object for the geometry column * test/test_postgis_db.py (TestPostGISConnection.test_gis_tables_non_empty): Removed. Subsumed by the new: (TestPostGISConnection.test_gis_tables_with_views_and_tables): New. Tes the GeometryTables and table_columns methods with actual tables and views. (PointTests.test_id_column, PointTests.test_geometry_column): New. tests for the new methods. (TestPostGISShapestorePoint.setUp) (TestPostGISShapestorePointSRID.setUp) (TestPostGISShapestorePointExplicitGIDColumn.setUp): Fill the instance variables needed by the new tests
* Thuban/Model/postgisdb.py (PostGISTable.__init__): New parameter id_column to specify which column to use to identify rows. Also new instance variables id_column and quoted_id_column (PostGISTable.RowIdToOrdinal, PostGISTable.RowOrdinalToId) (PostGISTable.ReadRowAsDict, PostGISTable.ReadValue) (PostGISTable.SimpleQuery): Use the id column name provided to the constructor instead of "gid" (PostGISShapeStore.__init__): New parameter id_column analogously to PostGISTable.__init__. This parameter is simply passed through to the base class constructor (PostGISShapeStore._create_col_from_description): Fix typo in doc-string (PostGISShapeStore.Shape, PostGISShapeStore.AllShapes) (PostGISShapeStore.ShapesInRegion): Use the id column name provided to the constructor instead of "gid" * test/postgissupport.py (PostgreSQLServer.get_default_static_data_db): New static table landmarks_point_id with an id column != "gid. Update the comments a bit. (skip_if_addgeometrycolumn_does_not_use_quote_ident): Fix typo in doc- (upload_shapefile): New parameter gid_column to use a name other than "gid" for the column to store the shape ids * test/test_postgis_db.py (TableTests): New. Mixin-class containing all tests previously in TestPostGISTable. The actual tests are the same but the code is a bit more configurable to allow for different id columns etc. (TestPostGISTable): Derive from TableTests now for the actual tests. (TestPostGISTableExplicitGIDColumn): New. Like TestPostGISTable except that it the landmarks_point_id table to test the id_column parameter (PointTests): Extend the doc-string (TestPostGISShapestorePointExplicitGIDColumn) (TestPostGISShapestorePointOIDAsGIDColumn): New classes derived from PointTests to test the explicit id_column parameter. One tests with the name of the column holding the shape ids, the other uses PostgreSQL's OID column. For the latter a number of methods have to be overwritten to make them independent of the actual id values.
* Thuban/Model/postgisdb.py (PostGISTable._fetch_table_information): Delegate the creation of column objects to a different method so that we can extend that in derived classes (PostGISTable._create_col_from_description): New. Column object creation part of _fetch_table_information (PostGISShapeStore._create_col_from_description): New. Extend inherited method to handle geometry columns (PostGISShapeStore.__init__): New parameter geometry_column to specify which geometry column to use. Optional but mandatory for tables with more than one geometry column (PostGISShapeStore._fetch_table_information): Also use the name of the geometry column when looking for the srid (PostGISShapeStore.ShapeType): Also use the name of the geometry column when looking for the shape type * test/test_save.py (SaveSessionTest.test_save_postgis): Adapt NonConnectionStore to changes in the PostGISShapeStore * test/test_postgis_db.py (TestPostGISSpecialCases.test_shapestore_two_geom_cols): Test PostGISShapeStore with tables having two geometry columns.
* Thuban/Model/postgisdb.py (quote_identifier): Fix typo in doc-string (PostGISShapeStore._fetch_table_information): New. Extend inherited method to retrieve srid (PostGISShapeStore.BoundingBox): Handle tables without data. extent yields NULL for those (PostGISShapeStore.ShapesInRegion): Use the srid of the table. * test/test_postgis_db.py (TestPostGISSpecialCases.test_shapestore_empty_table): New test for the special case of a table without any data (TestPostGISShapestorePointSRID): New class with tests for a table that uses srids (PolygonTests): Fix a doc-string typo * test/postgissupport.py (PostGISDatabase.__init__): New parameter reference_systems with a specification of spacial reference systems to create in the new db. (PostgreSQLServer.new_postgis_db) (PostgreSQLServer.get_static_data_db): New parameter reference_systems to be passed through ultimately to PostGISDatabase. In new_postgis_db also check whether an existing db already has the right srids (PostgreSQLServer.get_default_static_data_db): Add srids and a table that uses srids (PostGISDatabase.initdb): Create the entries for the reference systems (PostGISDatabase.has_data): Add reference_systems parameter to check for those too (upload_shapefile): New parameter srid to create tables with a specific srid
(PostGISConnection.MatchesParameters): New. Test whether the connection matches a set of connection parameters
Quote table and column names properly for postgis. (quote_identifier): New. Function to quote an identifier for use in an sql statement (PostGISColumn.__init__): Add the quoted_name attribute (PostGISTable.__init__): New instance variable quoted_tablename (PostGISTable._fetch_table_information): Use the quoted table name. New isntance variable quoted_geo_col with a quoted version of geometry_column (PostGISTable.NumRows, PostGISTable.RowIdToOrdinal) (PostGISTable.RowOrdinalToId): Use the quoted table name (PostGISTable.ReadValue, PostGISTable.ValueRange) (PostGISTable.UniqueValues, PostGISTable.SimpleQuery) (PostGISShapeStore.BoundingBox, PostGISShapeStore.Shape) (PostGISShapeStore.AllShapes, PostGISShapeStore.ShapesInRegion): Use quoted table and column names
* Thuban/Model/postgisdb.py (PostGISTable): Extend doc-string (PostGISTable._fetch_table_information): Set the column index correctly, pretending ignored columns don't exist. * test/test_postgis_db.py (TestPostGISIgnoredColumns): New tests for postgis tables with data types not yet supported by thuban.
Make the table interface distinguish between row ids (an integer that uniquely identifies a row) and row ordinals (a simple row count from 0 to NumRows() - 1) * Thuban/Model/postgisdb.py (PostGISTable.RowIdToOrdinal) (PostGISTable.RowOrdinalToId): New methods to conver between row ids and row ordinals (PostGISTable.ReadRowAsDict, PostGISTable.ReadValue): New keyword parameter row_is_ordinal to indicate whether the row parameter is the row id or the ordinal * Thuban/Model/transientdb.py (TransientTableBase.RowIdToOrdinal) (TransientTableBase.RowOrdinalToId) (AutoTransientTable.RowIdToOrdinal) (AutoTransientTable.RowOrdinalToId): Same new methods as in PostGISTable. (TransientTableBase.ReadRowAsDict, TransientTableBase.ReadValue) (AutoTransientTable.ReadRowAsDict, AutoTransientTable.ReadValue): Same new parameter as in PostGISTable. * Thuban/Model/table.py (DBFTable.RowIdToOrdinal) (DBFTable.RowOrdinalToId, MemoryTable.RowIdToOrdinal) (MemoryTable.RowOrdinalToId): Same new methods as in PostGISTable. (DBFTable.ReadValue, DBFTable.ReadRowAsDict) (MemoryTable.ReadValue, MemoryTable.ReadRowAsDict): Same new parameter as in PostGISTable. * Thuban/UI/tableview.py (DataTable.RowIdToOrdinal) (DataTable.RowOrdinalToId): New methods to convert between row ids and row ordinals. (TableGrid.SelectRowById): New method to select a row based on its ID as opposed to its ordinal (DataTable.GetValue, TableGrid.OnRangeSelect) (TableGrid.OnSelectCell, LayerTableGrid.select_shapes) (QueryTableFrame.OnQuery, QueryTableFrame.get_selected) (LayerTableFrame.__init__): Convert between row ids and row ordinals as appropriate * test/postgissupport.py (PostGISDatabase.__init__): Add doc-string. (PostGISDatabase.initdb): The optional third item in a tuple in tables is now a (key, value) list with additional arguments to pass to upload_shapefile (upload_shapefile): New parameter gid_offset to allow gids that are not the same as the shapeids in the shapefile (PostgreSQLServer.get_default_static_data_db): Use the new gid_offset to make the gids in landmarks 1000 higher than the shapeids in the shapefile * test/test_viewport.py (TestViewportWithPostGIS.test_find_shape_at_point): Adapt to the new shapeids in the landmarks table * test/test_transientdb.py (TestTransientTable.run_iceland_political_tests) (TestTransientTable.test_transient_joined_table): Add tests for the new table methods and new keywords arguments. * test/test_postgis_db.py (TestPostGISTable.test_read_row_as_dict_row_count_mode) (TestPostGISTable.test_read_value_row_count_mode) (TestPostGISTable.test_row_id_to_ordinal) (TestPostGISTable.test_row_oridnal_to_id): New test for the new table methods and the new arguments (TestPostGISShapestorePoint.test_shapes_in_region) (TestPostGISShapestorePoint.test_shape_raw_data) (TestPostGISShapestorePoint.test_shape_points) (TestPostGISShapestorePoint.test_shape_shapeid) (TestPostGISShapestorePoint.test_all_shapes) (TestPostGISTable.test_simple_query) (TestPostGISTable.test_simple_query) (TestPostGISTable.test_simple_query) (TestPostGISTable.test_read_value) (TestPostGISTable.test_read_row_as_dict): Adapt to the new shapeids in the landmarks table * test/test_memory_table.py (TestMemoryTable.test_read_row_as_dict_row_count_mode) (TestMemoryTable.test_read_value_row_count_mode) (TestMemoryTable.test_row_id_to_ordinal) (TestMemoryTable.test_row_oridnal_to_id): New test for the new table methods and the new arguments * test/test_dbf_table.py (TestDBFTable.test_read_row_as_dict_row_count_mode) (TestDBFTable.test_read_value_row_count_mode) (TestDBFTable.test_row_id_to_ordinal) (TestDBFTable.test_row_oridnal_to_id): New test for the new table methods and the new arguments
(PostGISShapeStore.BoundingBox): Use a more postgis specific but much faster method to get the bounding box
* Thuban/Model/postgisdb.py (PostGISTable.Title) (PostGISShapeStore.AllShapes): Add these missing methods. (PostGISShapeStore.ShapesInRegion): No need to raise StopIteration. We can simply return * test/test_postgis_db.py (TestPostGISTable.test_title) (TestPostGISShapestorePoint.test_all_shapes): New tests for the new methods
* Thuban/Model/postgisdb.py (shapetype_map): Add MUTLIPOLYGON. * test/test_postgis_db.py (PolygonTests): New class containing those tests from TestPostGISShapestorePolygon that can also be used to test MUTLIPOLYGON tables (TestPostGISShapestorePolygon): Most tests are now in PolygonTests so derive from that (TestPostGISShapestoreMultiPolygon): New class with tests for MUTLIPOLYGON tables * test/postgissupport.py (PostGISDatabase.initdb): Allow the tables argument to have tuples with three items to override the WKT type used. (PostgreSQLServer.get_default_static_data_db): Use the above to create a polygon table with MUTLIPOLYGONs (point_to_wkt, coords_to_point, polygon_to_wkt, coords_to_polygon) (arc_to_wkt, coords_to_multilinestring): Rename from *_to_wkt to coords_to* (coords_to_multipolygon): New. Convert to MUTLIPOLYGON (wkt_converter): New. Map WKT types to converters (upload_shapefile): New parameter force_wkt_type to use a different WKT type than the default
Implement saving a session with a postgis connection * Resources/XML/thuban-0.9.dtd (dbconnection, dbshapesource) New elements for database connections and shapestores using db connections (session): Add the dbconnections to the content model * Thuban/Model/save.py (SessionSaver.write_db_connections): New. Write the db connections (SessionSaver.write_session): Call write_db_connections to write the connection before the data sources (SessionSaver.write_data_containers): Handle postgis shapestores * test/test_save.py (SaveSessionTest.thubanids) (SaveSessionTest.thubanidrefs): Update for new DTD (SaveSessionTest.test_save_postgis): New. Test saving a session with postgis connections * Thuban/Model/postgisdb.py (PostGISTable.DBConnection) (PostGISTable.TableName): New accessor methods for the connection and table name * test/test_postgis_db.py (TestPostGISTable.test_dbconn) (TestPostGISTable.test_dbname): New methods to test the new PostGISConnection methods
* Thuban/Model/postgisdb.py (ConnectionError): New exception class for exceptions occurring when establishing a Database connection (PostGISConnection.connect): Catch psycopg.OperationalError during connects and raise ConnectionError. * test/test_postgis_db.py (TestPostgisDBExceptions): New class for tests for database exceptions
* Thuban/UI/about.py (About.__init__): Add the psycopg version. * Thuban/version.py: Add psycopg version * Thuban/Model/postgisdb.py (psycopg_version): New. Return the version of the psycopg module
Make postgis support really optional including insensitive menu items. * Thuban/Model/postgisdb.py (has_postgis_support): New. Return whether the postgis is supported. * Thuban/UI/dbdialog.py: Put the psycopg import into try..except to make postgis support optional * Thuban/UI/mainwindow.py (_has_postgis_support): New. Context version of Thuban.Model.postgisdb.has_postgis_support (database_management command): Make it only sensitive if postgis is supported.
Add dialogs and commands to open database connections and add database layers. * Thuban/UI/mainwindow.py (MainWindow.DatabaseManagement): New method to open the database connection management dialog (MainWindow.AddDBLayer): New method to add a layer from a database (_has_dbconnections): New helper function to use for sensitivity (database_management command, layer_add_db command): New commands that call the above new methods. (main_menu): Add the new commands to the menu. * Thuban/Model/postgisdb.py (PostGISConnection.__init__) (PostGISConnection.connect): Establish the actual connection in a separate method and call it in __init__. This makes it easier to override the behavior in test cases (PostGISConnection.BriefDescription): New method to return a brief description for use in dialogs. * test/test_postgis_db.py (NonConnection): DB connection that doesn't actually connect (TestBriefDescription): New class with tests for the new BriefDescription method
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
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 |