[fdo-commits] r681 -
branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Mon Jan 22 21:22:07 EST 2007
Author: mloskot
Date: 2007-01-22 21:22:07 -0500 (Mon, 22 Jan 2007)
New Revision: 681
Added:
branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.cpp
branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.h
branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.cpp
branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.h
Log:
Preparation for specialized version of SpatialContextGroupReader/Writer for PostGIS. The specialization will override PostGIS incompatible behavior in Generic RDBMS layer.
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.cpp 2007-01-23 02:20:20 UTC (rev 680)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.cpp 2007-01-23 02:22:07 UTC (rev 681)
@@ -0,0 +1,77 @@
+//
+// Copyright (C) 2006 Refractions Research, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#include "stdafx.h"
+#include "SpatialContextGroupReader.h"
+#include <Sm/Ph/SpatialContextGroupReader.h>
+#include <Sm/Ph/SpatialContextGroupWriter.h>
+#include <Sm/Ph/Mt/SpatialContextGroupReader.h>
+#include <Sm/Ph/Rd/SpatialContextGroupReader.h>
+
+FdoSmPhPostGisSpatialContextGroupReader::FdoSmPhPostGisSpatialContextGroupReader(
+ FdoSmPhMgrP physicalSchema)
+ : FdoSmPhSpatialContextGroupReader(physicalSchema)
+{
+ physicalSchema->ColNameMaxLen();
+}
+
+FdoSmPhPostGisSpatialContextGroupReader::~FdoSmPhPostGisSpatialContextGroupReader(void)
+{
+}
+
+FdoSmPhReaderP FdoSmPhPostGisSpatialContextGroupReader::MakeReader( FdoSmPhMgrP mgr )
+{
+ FdoSmPhReaderP pSubReader;
+
+ // Create the row collection describing class attributes.
+ FdoSmPhRowsP rows = new FdoSmPhRowCollection();
+
+ FdoSmPhRowP scgRow = FdoSmPhSpatialContextGroupWriter::MakeRow(mgr);
+ rows->Add( scgRow );
+
+ // TODO: add handling for spatial contexts in configuration files.
+
+ // FdoSchemaMappingsP mappings = mgr->GetConfigMappings();
+
+ // if ( mappings )
+ // {
+ // // Config document is set so read spatial context groups from it.
+ // ...
+ // }
+ // else
+ // {
+ if (FdoSmPhOwnerP(mgr->GetOwner())->GetHasMetaSchema()
+ && FdoSmPhDbObjectP(scgRow->GetDbObject())->GetExists())
+ {
+ // F_SPATIALCONTEXTGROUP exists, read from MetaSchema
+ pSubReader = MakeMtReader(rows, mgr);
+ }
+ else
+ {
+ // F_SPATIALCONTEXTGROUP does not exist, read from native physical schema.
+
+ // TODO: mloskot - Temporarily disabled
+ pSubReader = NULL; // MakeRdReader( rows, mgr );
+ }
+ // }
+
+ return pSubReader;
+}
+
+FdoSmPhReaderP FdoSmPhPostGisSpatialContextGroupReader::MakeMtReader( FdoSmPhRowsP rows, FdoSmPhMgrP mgr )
+{
+ return new FdoSmPhMtSpatialContextGroupReader( rows, mgr );
+}
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.h
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.h 2007-01-23 02:20:20 UTC (rev 680)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupReader.h 2007-01-23 02:22:07 UTC (rev 681)
@@ -0,0 +1,50 @@
+//
+// Copyright (C) 2006 Refractions Research, Inc.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of version 2.1 of the GNU Lesser
+// General Public License as published by the Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+//
+#ifndef FDOSMPHPOSTGISSPATIALCONTEXTGROUPREADER_H
+#define FDOSMPHPOSTGISSPATIALCONTEXTGROUPREADER_H
+
+#include <Sm/Ph/Reader.h>
+
+/// Retrieves all spatial contexts from current PostGIS datastore.
+///
+class FdoSmPhPostGisSpatialContextGroupReader : public FdoSmPhSpatialContextGroupReader
+{
+public:
+
+ FdoSmPhPostGisSpatialContextGroupReader(FdoSmPhMgrP mgr);
+
+ ~FdoSmPhPostGisSpatialContextGroupReader(void);
+
+protected:
+
+ /// Unused constructor needed only to build on Linux
+ FdoSmPhPostGisSpatialContextGroupReader() {}
+
+ /// Top level function for creating inner reader
+ FdoSmPhReaderP MakeReader(FdoSmPhMgrP mgr);
+
+ /// Create inner reader for MetaSchema
+ FdoSmPhReaderP MakeMtReader(FdoSmPhRowsP rows, FdoSmPhMgrP mgr);
+
+private:
+
+};
+
+typedef FdoPtr<FdoSmPhPostGisSpatialContextGroupReader>
+ FdoSmPhPostGisSpatialContextGroupReaderP;
+
+#endif // FDOSMPHPOSTGISSPATIALCONTEXTGROUPREADER_H
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.cpp
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.cpp 2007-01-23 02:20:20 UTC (rev 680)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.cpp 2007-01-23 02:22:07 UTC (rev 681)
@@ -0,0 +1,251 @@
+/*
+ * Copyright (C) 2004-2006 Autodesk, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2.1 of the GNU Lesser
+ * General Public License as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "stdafx.h"
+#include <Sm/Ph/SpatialContextGroupWriter.h>
+#include <Sm/Ph/Rd/QueryReader.h>
+#include <Sm/Ph/CommandWriter.h>
+
+
+FdoSmPhSpatialContextGroupWriter::FdoSmPhSpatialContextGroupWriter(FdoSmPhMgrP mgr) :
+ FdoSmPhWriter( MakeWriter(mgr) )
+{
+}
+
+FdoSmPhSpatialContextGroupWriter::~FdoSmPhSpatialContextGroupWriter(void)
+{
+}
+
+FdoInt64 FdoSmPhSpatialContextGroupWriter::GetId()
+{
+ return( (FdoInt64) GetLong(L"", L"scgid") );
+}
+
+FdoStringP FdoSmPhSpatialContextGroupWriter::GetCrsName()
+{
+ return(GetString(L"", L"crsname"));
+}
+
+FdoStringP FdoSmPhSpatialContextGroupWriter::GetCrsWkt()
+{
+ return(GetString(L"", L"crswkt"));
+}
+
+FdoInt64 FdoSmPhSpatialContextGroupWriter::GetSrid()
+{
+ // TODO: get FdoInt64 when underlying support exists.
+ return( (FdoInt64) GetLong(L"", L"srid") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetXTolerance()
+{
+ return( GetDouble(L"", L"xtolerance") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetZTolerance()
+{
+ return( GetDouble(L"", L"ztolerance") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetXMin()
+{
+ // TODO: mloskot - xmin is a reserved keyword in PostgreSQL
+ return( GetDouble(L"", L"minx") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetYMin()
+{
+ // TODO: mloskot - ymin is a reserved keyword in PostgreSQL
+ return( GetDouble(L"", L"miny") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetZMin()
+{
+ // TODO: mloskot - zmin is NOT a reserved keyword in PostgreSQL,
+ // but renamed for consistency
+ return( GetDouble(L"", L"minz") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetXMax()
+{
+ // TODO: mloskot - xmax is a reserved keyword in PostgreSQL
+ return( GetDouble(L"", L"maxx") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetYMax()
+{
+ // TODO: mloskot - ymax is a reserved keyword in PostgreSQL
+ return( GetDouble(L"", L"maxy") );
+}
+
+double FdoSmPhSpatialContextGroupWriter::GetZMax()
+{
+ // TODO: mloskot - zmax is NOT a reserved keyword in PostgreSQL,
+ // but renamed for consistency
+ return( GetDouble(L"", L"maxz") );
+}
+
+FdoStringP FdoSmPhSpatialContextGroupWriter::GetExtentType()
+{
+ return(GetString(L"", L"extenttype"));
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetId( FdoInt64 lValue)
+{
+ // TODO: pass FdoInt64 when underlying support exists.
+ SetLong(L"", L"scgid", (long) lValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetCrsName(FdoStringP sValue)
+{
+ SetString(L"", L"crsname", sValue );
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetCrsWkt(FdoStringP sValue)
+{
+ SetString(L"", L"crswkt", sValue );
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetSrid(FdoInt64 lValue)
+{
+ // TODO: pass FdoInt64 when underlying support exists.
+ SetLong(L"", L"srid", (long) lValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetXTolerance(double dValue)
+{
+ SetDouble(L"", L"xtolerance", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetZTolerance(double dValue)
+{
+ SetDouble(L"", L"ztolerance", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetXMin(double dValue)
+{
+ // TODO: mloskot - xmin is a reserved keyword in PostgreSQL
+ SetDouble(L"", L"minx", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetYMin(double dValue)
+{
+ // TODO: mloskot - ymin is a reserved keyword in PostgreSQL
+ SetDouble(L"", L"miny", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetZMin(double dValue)
+{
+ // TODO: mloskot - zmin is NOT a reserved keyword in PostgreSQL,
+ // but renamed for consistency
+ SetDouble(L"", L"minz", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetXMax(double dValue)
+{
+ // TODO: mloskot - xmax is a reserved keyword in PostgreSQL
+ SetDouble(L"", L"maxx", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetYMax(double dValue)
+{
+ // TODO: mloskot - maxy is a reserved keyword in PostgreSQL
+ SetDouble(L"", L"maxy", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetZMax(double dValue)
+{
+ // TODO: mloskot - zmax is NOT a reserved keyword in PostgreSQL,
+ // but renamed for consistency
+ SetDouble(L"", L"maxz", dValue);
+}
+
+void FdoSmPhSpatialContextGroupWriter::SetExtentType(FdoStringP sValue)
+{
+ SetString(L"", L"extenttype", sValue );
+}
+
+void FdoSmPhSpatialContextGroupWriter::Add()
+{
+ FdoSmPhWriter::Add();
+}
+
+void FdoSmPhSpatialContextGroupWriter::Modify( FdoInt64 scId )
+{
+ FdoSmPhWriter::Modify(
+ FdoStringP::Format(
+#ifdef _WIN32
+ L"where scgid = %I64d",
+#else
+ L"where scgid = %lld",
+#endif
+ scId )
+ );
+}
+
+void FdoSmPhSpatialContextGroupWriter::Delete( FdoInt64 scId )
+{
+ if ( scId >= 0 ) {
+ FdoSmPhWriter::Delete(
+ FdoStringP::Format(
+#ifdef _WIN32
+ L"where scgid = %I64d",
+#else
+ L"where scgid = %lld",
+#endif
+ scId
+ )
+ );
+ }
+}
+
+FdoSmPhRowP FdoSmPhSpatialContextGroupWriter::MakeRow( FdoSmPhMgrP mgr )
+{
+ bool hasMs = FdoSmPhOwnerP(mgr->GetOwner())->GetHasMetaSchema();
+ FdoStringP scgDefTable = mgr->GetDcDbObjectName(L"f_spatialcontextgroup");
+
+ FdoSmPhRowP row = new FdoSmPhRow(
+ mgr,
+ L"f_spatialcontextgroup",
+ hasMs ? mgr->FindDbObject(scgDefTable) : FdoSmPhDbObjectP()
+ );
+
+ // Each field adds itself to the row
+ FdoSmPhFieldP field = new FdoSmPhField( row, L"scgid", (FdoSmPhColumn*) NULL, L"0" );
+ field = new FdoSmPhField( row, L"crsname", (FdoSmPhColumn*) NULL, L"" );
+ field = new FdoSmPhField( row, L"crswkt", row->CreateColumnChar(L"crswkt", true, 2048 ) );
+ field = new FdoSmPhField( row, L"srid", (FdoSmPhColumn*) NULL, L"" );
+ field = new FdoSmPhField( row, L"xtolerance", (FdoSmPhColumn*) NULL, L"0.001" );
+ field = new FdoSmPhField( row, L"ztolerance", (FdoSmPhColumn*) NULL, L"0.001" );
+ field = new FdoSmPhField( row, L"minx", (FdoSmPhColumn*) NULL, L"-2000000" );
+ field = new FdoSmPhField( row, L"miny", (FdoSmPhColumn*) NULL, L"-2000000" );
+ field = new FdoSmPhField( row, L"minz", (FdoSmPhColumn*) NULL, L"-2000000" );
+ field = new FdoSmPhField( row, L"maxx", (FdoSmPhColumn*) NULL, L"2000000" );
+ field = new FdoSmPhField( row, L"maxy", (FdoSmPhColumn*) NULL, L"2000000" );
+ field = new FdoSmPhField( row, L"maxz", (FdoSmPhColumn*) NULL, L"2000000" );
+ field = new FdoSmPhField( row, L"extenttype", (FdoSmPhColumn*) NULL, L"S" );
+
+ return( row );
+}
+
+FdoSmPhWriterP FdoSmPhSpatialContextGroupWriter::MakeWriter( FdoSmPhMgrP mgr )
+{
+ FdoSmPhCommandWriterP subWriter = mgr->CreateCommandWriter( MakeRow(mgr) );
+
+ return subWriter.p->SmartCast<FdoSmPhWriter>();
+}
Added: branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.h
===================================================================
--- branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.h 2007-01-23 02:20:20 UTC (rev 680)
+++ branches/fdordbms-postgis/Providers/GenericRdbms/Src/PostGIS/SchemaMgr/Ph/SpatialContextGroupWriter.h 2007-01-23 02:22:07 UTC (rev 681)
@@ -0,0 +1,131 @@
+#ifndef FDOSMPHSPATIALCONTEXTGROUPWRITER_H
+#define FDOSMPHSPATIALCONTEXTGROUPWRITER_H 1
+/*
+ * Copyright (C) 2004-2006 Autodesk, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2.1 of the GNU Lesser
+ * General Public License as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <Sm/Ph/Writer.h>
+#include <Sm/Ph/Mgr.h>
+#include <Sm/Ph/Row.h>
+
+// This class writes spatial context group definitions
+// to the f_spatialcontextgroup table.
+class FdoSmPhSpatialContextGroupWriter : public FdoSmPhWriter
+{
+public:
+
+ /// Create a spatial context group writer.
+ //
+ /// Parameters:
+ /// mgr: holds the connection for the datastore to use.
+ FdoSmPhSpatialContextGroupWriter(FdoSmPhMgrP mgr);
+
+ ~FdoSmPhSpatialContextGroupWriter(void);
+
+ /// Various field value getters
+
+ /// Spatial Context Group ID - internal to Provider
+ FdoInt64 GetId();
+
+ /// Coordinate Reference System name
+ FdoStringP GetCrsName();
+
+ /// Coordinate Reference System definition in OpenGIS WKT format
+ FdoStringP GetCrsWkt();
+
+ /// Spatial Reference ID (if not zero, must agree with CrsName).
+ FdoInt64 GetSrid();
+
+ /// Tolerances and extents
+ double GetXTolerance();
+ double GetZTolerance();
+ double GetXMin();
+ double GetYMin();
+ double GetZMin();
+ double GetXMax();
+ double GetYMax();
+ double GetZMax();
+
+ /// Extent Type -- immutable 'S' (static) or updatable 'D' (dynamic)
+ FdoStringP GetExtentType();
+
+ /// Corresponding setter functions. There's none for scgid
+ /// since it is autogenerated when a new spatial context group is written.
+
+ /// Coordinate Reference System name
+ void SetCrsName(FdoStringP sValue);
+
+ /// Coordinate Reference System definition in OpenGIS WKT format
+ void SetCrsWkt(FdoStringP sValue);
+
+ /// Spatial Reference ID (if not zero, must agree with CrsName).
+ void SetSrid(FdoInt64 lValue);
+
+ /// Tolerances and extents
+ void SetXTolerance(double dValue);
+ void SetZTolerance(double dValue);
+ void SetXMin(double dValue);
+ void SetYMin(double dValue);
+ void SetZMin(double dValue);
+ void SetXMax(double dValue);
+ void SetYMax(double dValue);
+ void SetZMax(double dValue);
+
+ /// Extent Type -- immutable 'S' (static) or updatable 'D' (dynamic)
+ void SetExtentType(FdoStringP sValue);
+
+ /// Add the current row as a new spatial context group
+ virtual void Add();
+
+ /// Modify a spatial context group using the current field values.
+ //
+ /// Parameters
+ /// scId: primary key of the spatial context group to modify
+ virtual void Modify( FdoInt64 scgId );
+
+ /// Delete a spatial context group using the current field values.
+ //
+ /// Parameters
+ /// scgId: primary key of the spatial context group to delete
+ virtual void Delete( FdoInt64 scgId );
+
+ /// Get a field list for reading from or writing to
+ /// f_spatialcontextgroup.
+ //
+ /// Parameters:
+ /// physicalSchema: holds the connection for the datastore to query.
+ static FdoSmPhRowP MakeRow( FdoSmPhMgrP mgr );
+
+protected:
+ /// Unused constructor needed only to build on Linux
+ FdoSmPhSpatialContextGroupWriter() {}
+
+
+ FdoSmPhWriterP MakeWriter( FdoSmPhMgrP mgr );
+
+ void SetId( FdoInt64 lValue);
+};
+
+typedef FdoPtr<FdoSmPhSpatialContextGroupWriter> FdoSmPhSpatialContextGroupWriterP;
+
+#endif
+
+
More information about the fdo-commits
mailing list