private static void ProcessFilterCapabilities(FdoIConnection conn) { using (var caps = conn.GetFilterCapabilities()) { Log("Filter Capabilities"); Log("\tSupportedConditionTypes:"); var condTypes = caps.SupportedConditionTypes(); for (int i = 0; i < condTypes.Count; i++) { Log("\t\t{0}", condTypes.GetItem(i)); } Log("\tSupportedDistanceOperations:"); var distOps = caps.SupportedDistanceOperations(); for (int i = 0; i < distOps.Count; i++) { Log("\t\t{0}", distOps.GetItem(i)); } Log("\tSupportedSpatialOperations:"); var spOps = caps.SupportedSpatialOperations(); for (int i = 0; i < spOps.Count; i++) { Log("\t\t{0}", spOps.GetItem(i)); } Log("\tSupportsGeodesicDistance: {0}", caps.SupportsGeodesicDistance()); Log("\tSupportsNonLiteralGeometricOperations: {0}", caps.SupportsNonLiteralGeometricOperations()); } }
private void DoDistinct(FdoIConnection conn) { FdoISelectAggregates selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_SelectAggregates) as FdoISelectAggregates; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.Distinct = true; FdoIdentifierCollection propNames = selectCmd.GetPropertyNames(); FdoIdentifier ident = FdoIdentifier.Create("NAME"); propNames.Add(ident); FdoIDataReader rdr = selectCmd.Execute(); HashSet <string> values = new HashSet <string>(); int count = 0; while (rdr.ReadNext()) { values.Add(rdr.GetString("NAME")); count++; } rdr.Close(); Assert.Equal(values.Count, count); }
private static void ProcessGeometryCapabilities(FdoIConnection conn) { using (var caps = conn.GetGeometryCapabilities()) { Log("Geometry Capabilities"); int dims = caps.GetDimensionalities(); Log("\tDimensionalities:"); foreach (FdoDimensionality dim in Enum.GetValues(typeof(FdoDimensionality))) { int d = (int)dim; Log("\t\t{0} - {1}", dim, ((dims & d) == d)); } Log("\tSupportedGeometryComponentTypes:"); var geomCompTypes = caps.SupportedGeometryComponentTypes(); for (int i = 0; i < geomCompTypes.Count; i++) { var gct = geomCompTypes.GetItem(i); Log("\t\t{0}", gct); } Log("\tSupportedGeometryTypes:"); var geomTypes = caps.SupportedGeometryTypes(); for (int i = 0; i < geomTypes.Count; i++) { var gt = geomTypes.GetItem(i); Log("\t\t{0}", gt); } } }
public void DescribeSHPSchema() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SHP"); conn.ConnectionString = "DefaultFileLocation=" + TestDataStore.SHP; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.Equal(1, schemas.Count); FdoFeatureSchema schema = schemas.GetItem(0); FdoClassCollection classes = schema.GetClasses(); Assert.Equal(1, classes.Count); FdoClassDefinition clsDef = classes.GetItem(0); VerifyClass(clsDef); //Re-test with sugar clsDef = schemas.GetClassDefinition(schema.Name, "World_Countries"); Assert.NotNull(clsDef); VerifyClass(clsDef); clsDef = schemas.GetClassDefinition(null, "World_Countries"); Assert.NotNull(clsDef); VerifyClass(clsDef); Assert.Throws <ManagedFdoException>(() => schemas.GetClassDefinition(null, "WorldCountries")); Assert.Throws <ManagedFdoException>(() => schemas.GetClassDefinition("BogusSchema", "World_Countries")); }
private static void ProcessRasterCapabilities(FdoIConnection conn) { using (var caps = conn.GetRasterCapabilities()) { Log("Raster Capabilities"); Log("\tSupportsRaster: {0}", caps.SupportsRaster()); Log("\tSupportsStitching: {0}", caps.SupportsStitching()); Log("\tSupportsSubsampling: {0}", caps.SupportsSubsampling()); } }
private static void ProcessTopologyCapabilities(FdoIConnection conn) { Log("Topology Capabilities"); using (var caps = conn.GetTopologyCapabilities()) { Log("\tActivatesTopologyByArea: {0}", caps.ActivatesTopologyByArea()); Log("\tBreaksCurveCrossingsAutomatically: {0}", caps.BreaksCurveCrossingsAutomatically()); Log("\tConstrainsFeatureMovements: {0}", caps.ConstrainsFeatureMovements()); Log("\tSupportsTopologicalHierarchy: {0}", caps.SupportsTopologicalHierarchy()); Log("\tSupportsTopology: {0}", caps.SupportsTopology()); } }
private void DoGetSpatialContexts(FdoIConnection conn) { FdoIGetSpatialContexts cmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_GetSpatialContexts) as FdoIGetSpatialContexts; Assert.NotNull(cmd); FdoISpatialContextReader scReader = cmd.Execute(); int count = 0; while (scReader.ReadNext()) { Assert.NotNull(scReader.Name); Assert.NotEmpty(scReader.Name); count++; } Assert.Equal(1, count); }
public void TestSQLite() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SQLite"); conn.ConnectionString = "File=" + TestDataStore.SQLITE; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); conn.Close(); conn.ConnectionString = "File=../IDontExist.sqlite"; Assert.Throws <ManagedFdoException>(() => { FdoConnectionState state = conn.Open(); }); }
public void TestSQLiteSpatialContext() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SQLite"); conn.ConnectionString = "File=" + TestDataStore.SQLITE; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); try { DoGetSpatialContexts(conn); } finally { conn.Close(); } }
public void TestSDFDistinct() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SDF"); conn.ConnectionString = "File=" + TestDataStore.SDF; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); try { DoDistinct(conn); DoFilteredDistinct(conn); } finally { conn.Close(); } }
public void TestSHPSpatialExtents() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SHP"); conn.ConnectionString = "DefaultFileLocation=" + TestDataStore.SHP; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); try { DoSpatialExtents(conn); DoFilteredSpatialExtents(conn); } finally { conn.Close(); } }
public void TestSHPUpdate() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SHP"); conn.ConnectionString = "DefaultFileLocation=" + SHP; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); try { DoUpdate(conn); } finally { conn.Close(); } }
public void TestSQLiteCapabilities() { Log("\n====== Testing SQLite Capabilities =======\n"); IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SQLite"); conn.ConnectionString = "File=" + TestDataStore.SQLITE; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); ProcessCommandCapabilities(conn); ProcessConnectionCapabilities(conn); ProcessExpressionCapabilities(conn); ProcessFilterCapabilities(conn); ProcessGeometryCapabilities(conn); ProcessRasterCapabilities(conn); ProcessSchemaCapabilities(conn); ProcessTopologyCapabilities(conn); }
public void TestSQLiteSelectFiltered() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SQLite"); conn.ConnectionString = "File=" + TestDataStore.SQLITE; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); try { FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); TestFilteredSelectCommand(selectCmd); } finally { conn.Close(); } }
public void TestSHP() { IConnectionManager connMgr = FdoFeatureAccessManager.GetConnectionManager(); FdoIConnection conn = connMgr.CreateConnection("OSGeo.SHP"); conn.ConnectionString = "DefaultFileLocation=" + TestDataStore.SHP; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); conn.Close(); conn.ConnectionString = "DefaultFileLocation=" + TestDataStore.SHP_DIR; Assert.Equal(FdoConnectionState.FdoConnectionState_Open, conn.Open()); conn.Close(); conn.ConnectionString = "File=../IDontExist.shp"; Assert.Throws <ManagedFdoException>(() => { FdoConnectionState state = conn.Open(); }); }
private static void ProcessConnectionCapabilities(FdoIConnection conn) { using (var caps = conn.GetConnectionCapabilities()) { Log("Connection Capabilities"); int jtypes = caps.GetJoinTypes(); Log("\tJoinTypes:"); foreach (FdoJoinType jt in Enum.GetValues(typeof(FdoJoinType))) { Log("\t\t{0} - {1}", jt, ((jtypes & (int)jt) == (int)jt)); } Log("\tThreadCapability: {0}", caps.GetThreadCapability()); var ltypes = caps.SupportedLockTypes(); Log("\tSupportedLockTypes:"); for (int i = 0; i < ltypes.Count; i++) { Log("\t\t{0}", ltypes.GetItem(i)); } var sceTypes = caps.SupportedSpatialContextExtentTypes(); Log("\tSupportedSpatialContextExtentTypes:"); for (int i = 0; i < sceTypes.Count; i++) { Log("\t\t{0}", sceTypes.GetItem(i)); } Log("\tSupportsConfiguration: {0}", caps.SupportsConfiguration()); Log("\tSupportsCSysWKTFromCSysName: {0}", caps.SupportsCSysWKTFromCSysName()); Log("\tSupportsFlush: {0}", caps.SupportsFlush()); Log("\tSupportsJoins: {0}", caps.SupportsJoins()); Log("\tSupportsLocking: {0}", caps.SupportsLocking()); Log("\tSupportsLongTransactions: {0}", caps.SupportsLongTransactions()); Log("\tSupportsMultipleSpatialContexts: {0}", caps.SupportsMultipleSpatialContexts()); Log("\tSupportsMultiUserWrite: {0}", caps.SupportsMultiUserWrite()); Log("\tSupportsSavePoint: {0}", caps.SupportsSavePoint()); Log("\tSupportsSQL: {0}", caps.SupportsSQL()); Log("\tSupportsSubSelects: {0}", caps.SupportsSubSelects()); Log("\tSupportsTimeout: {0}", caps.SupportsTimeout()); Log("\tSupportsTransactions: {0}", caps.SupportsTransactions()); Log("\tSupportsWrite: {0}", caps.SupportsWrite()); } }
private void DoDelete(FdoIConnection conn) { string geomName = null; FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); FdoFeatureClass clsDef = schemas.GetClassDefinition(null, "World_Countries") as FdoFeatureClass; Assert.NotNull(clsDef); FdoGeometricPropertyDefinition geomProp = clsDef.GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; FdoIDelete deleteCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Delete) as FdoIDelete; Assert.NotNull(deleteCmd); deleteCmd.SetFeatureClassName("World_Countries"); deleteCmd.SetFilter("NAME = 'Canada'"); int updated = deleteCmd.Execute(); Assert.Equal(66, updated); FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIFeatureReader fr = selectCmd.Execute(); Assert.False(fr.ReadNext()); fr.Close(); }
private void DoFilteredCount(FdoIConnection conn) { FdoISelectAggregates selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_SelectAggregates) as FdoISelectAggregates; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIdentifierCollection propNames = selectCmd.GetPropertyNames(); FdoExpression countExpr = FdoExpression.Parse("COUNT(NAME)"); FdoComputedIdentifier countIdent = FdoComputedIdentifier.Create("TOTAL_COUNT", countExpr); propNames.Add(countIdent); FdoIDataReader rdr = selectCmd.Execute(); long total = 0; while (rdr.ReadNext()) { total += rdr.GetInt64("TOTAL_COUNT"); } rdr.Close(); Assert.Equal(66L, total); //Re-test with sugar methods propNames.Clear(); Assert.Equal(0, propNames.Count); propNames.AddComputedIdentifier("TOTAL_COUNT", "COUNT(NAME)"); Assert.Equal(1, propNames.Count); rdr = selectCmd.Execute(); total = 0; while (rdr.ReadNext()) { total += rdr.GetInt64("TOTAL_COUNT"); } rdr.Close(); Assert.Equal(66L, total); }
private static void ProcessCommandCapabilities(FdoIConnection conn) { Log("Command Capabilities"); using (var caps = conn.GetCommandCapabilities()) { var cmds = caps.SupportedCommands(); Log("\tSupportedCommands:"); for (int i = 0; i < cmds.Count; i++) { int cmdType = cmds.GetItem(i); try { FdoICommand cmd = conn.CreateCommand(cmdType); Log("\t\t{0}", ((FdoCommandType)cmdType).ToString()); if (Enum.IsDefined(typeof(FdoCommandType), cmdType)) { Assert.NotNull(cmd); ValidateCommandType(cmd, cmdType); } else { Log("\tWARNING: Non-standard FDO command {0} encountered", cmdType); } } catch (ManagedFdoException ex) { Assert.True(false, string.Format("Failed to create command ({0}). Cause: {1}", ((FdoCommandType)cmdType), ex.ToString())); } } Log("\tSupportsParameters: {0}", caps.SupportsParameters()); Log("\tSupportsSelectDistinct: {0}", caps.SupportsSelectDistinct()); Log("\tSupportsSelectExpressions: {0}", caps.SupportsSelectExpressions()); Log("\tSupportsSelectFunctions: {0}", caps.SupportsSelectFunctions()); Log("\tSupportsSelectGrouping: {0}", caps.SupportsSelectGrouping()); Log("\tSupportsSelectOrdering: {0}", caps.SupportsSelectOrdering()); Log("\tSupportsTimeout: {0}", caps.SupportsTimeout()); } }
private static int GetFeatureCountForMapKey(FdoIConnection conn, string key) { FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("MAPKEY = '" + key + "'"); FdoIFeatureReader selReader = selectCmd.Execute(); int count = 0; try { while (selReader.ReadNext()) { count++; } } finally { selReader.Close(); } return(count); }
private static void ProcessSchemaCapabilities(FdoIConnection conn) { Log("Schema Capabilities"); using (var caps = conn.GetSchemaCapabilities()) { Log("\tMaximumDataValueLength:"); foreach (FdoDataType dt in Enum.GetValues(typeof(FdoDataType))) { Log("\t\t{0} - {1}", dt, caps.GetMaximumDataValueLength(dt)); } Log("\tMaximumDecimalPrecision: {0}", caps.GetMaximumDecimalPrecision()); Log("\tMaximumDecimalScale: {0}", caps.GetMaximumDecimalScale()); Log("\tNameSizeLimit:"); foreach (FdoSchemaElementNameType snt in Enum.GetValues(typeof(FdoSchemaElementNameType))) { Log("\t\t{0} - {1}", snt, caps.GetNameSizeLimit(snt)); } Log("\tReservedCharactersForName: {0}", caps.GetReservedCharactersForName()); Log("\tSupportedAutogeneratedDataTypes:"); var dataTypes = caps.SupportedAutogeneratedDataTypes(); for (int i = 0; i < dataTypes.Count; i++) { var dt = dataTypes.GetItem(i); Log("\t\t{0}", dt); } var clsTypes = caps.SupportedClassTypes(); Log("\tSupportedClassTypes:"); for (int i = 0; i < clsTypes.Count; i++) { var clsType = clsTypes.GetItem(i); Log("\t\t{0}", clsType); } Log("\tSupportedDataTypes:"); dataTypes = caps.SupportedDataTypes(); for (int i = 0; i < dataTypes.Count; i++) { var dt = dataTypes.GetItem(i); Log("\t\t{0}", dt); } Log("\tSupportedIdentityPropertyTypes:"); dataTypes = caps.SupportedIdentityPropertyTypes(); for (int i = 0; i < dataTypes.Count; i++) { var dt = dataTypes.GetItem(i); Log("\t\t{0}", dt); } Log("\tSupportsAssociationProperties: {0}", caps.SupportsAssociationProperties()); Log("\tSupportsAutoIdGeneration: {0}", caps.SupportsAutoIdGeneration()); Log("\tSupportsCompositeId: {0}", caps.SupportsCompositeId()); Log("\tSupportsCompositeUniqueValueConstraints: {0}", caps.SupportsCompositeUniqueValueConstraints()); Log("\tSupportsDataStoreScopeUniqueIdGeneration: {0}", caps.SupportsDataStoreScopeUniqueIdGeneration()); Log("\tSupportsDefaultValue: {0}", caps.SupportsDefaultValue()); Log("\tSupportsExclusiveValueRangeConstraints: {0}", caps.SupportsExclusiveValueRangeConstraints()); Log("\tSupportsInclusiveValueRangeConstraints: {0}", caps.SupportsInclusiveValueRangeConstraints()); Log("\tSupportsInheritance: {0}", caps.SupportsInheritance()); Log("\tSupportsMultipleSchemas: {0}", caps.SupportsMultipleSchemas()); Log("\tSupportsNetworkModel: {0}", caps.SupportsNetworkModel()); Log("\tSupportsNullValueConstraints: {0}", caps.SupportsNullValueConstraints()); Log("\tSupportsObjectProperties: {0}", caps.SupportsObjectProperties()); Log("\tSupportsSchemaModification: {0}", caps.SupportsSchemaModification()); Log("\tSupportsSchemaOverrides: {0}", caps.SupportsSchemaOverrides()); Log("\tSupportsUniqueValueConstraints: {0}", caps.SupportsUniqueValueConstraints()); Log("\tSupportsValueConstraintsList: {0}", caps.SupportsValueConstraintsList()); } }
private void DoInsert(FdoIConnection conn) { string geomName = null; using (FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema) { Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); FdoFeatureClass clsDef = schemas.GetClassDefinition(null, "World_Countries") as FdoFeatureClass; Assert.NotNull(clsDef); FdoGeometricPropertyDefinition geomProp = clsDef.GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; } using (FdoIInsert insertCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Insert) as FdoIInsert) { Assert.NotNull(insertCmd); insertCmd.SetFeatureClassName("World_Countries"); FdoFgfGeometryFactory geomFactory = FdoFgfGeometryFactory.GetInstance(); FdoPropertyValueCollection propVals = insertCmd.GetPropertyValues(); FdoStringValue nameVal = FdoStringValue.Create(); Assert.True(nameVal.IsNull()); FdoStringValue keyVal = FdoStringValue.Create(); Assert.True(keyVal.IsNull()); FdoStringValue mapkeyVal = FdoStringValue.Create(); Assert.True(mapkeyVal.IsNull()); FdoGeometryValue geomVal = FdoGeometryValue.Create(); Assert.True(geomVal.IsNull()); FdoPropertyValue pName = FdoPropertyValue.Create("NAME", nameVal); FdoPropertyValue pKey = FdoPropertyValue.Create("KEY", keyVal); FdoPropertyValue pMapKey = FdoPropertyValue.Create("MAPKEY", mapkeyVal); FdoPropertyValue pGeom = FdoPropertyValue.Create(geomName, geomVal); propVals.Add(pName); propVals.Add(pKey); propVals.Add(pMapKey); propVals.Add(pGeom); //Set the actual values nameVal.String = "My Own Country"; keyVal.String = "MOC"; mapkeyVal.String = "MOC123"; FdoIGeometry geom = geomFactory.CreateGeometry("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"); FdoByteArrayHandle fgf = geomFactory.GetFgfBytes(geom); geomVal.SetGeometryBytes(fgf); int inserted = GetInsertedFeatures(insertCmd); Assert.Equal(1, inserted); int count = GetFeatureCountForName(conn, "My Own Country"); Assert.Equal(1, count); mapkeyVal.String = "MOC234"; Assert.Equal(1, GetInsertedFeatures(insertCmd)); //, "Expected 1 feature inserted"); Assert.Equal(2, GetFeatureCountForName(conn, "My Own Country")); Assert.Equal(1, GetFeatureCountForMapKey(conn, "MOC123")); Assert.Equal(1, GetFeatureCountForMapKey(conn, "MOC234")); } //Test sugar methods using (FdoIInsert insertCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Insert) as FdoIInsert) { Assert.NotNull(insertCmd); insertCmd.SetFeatureClassName("World_Countries"); FdoFgfGeometryFactory geomFactory = FdoFgfGeometryFactory.GetInstance(); FdoPropertyValueCollection propVals = insertCmd.GetPropertyValues(); propVals.SetStringValue("KEY", "MOC"); propVals.SetStringValue("MAPKEY", "MOC123"); propVals.SetStringValue("NAME", "My Own Country"); FdoIGeometry geom = geomFactory.CreateGeometry("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"); FdoByteArrayHandle fgf = geomFactory.GetFgfBytes(geom); propVals.SetGeometryValue("Geometry", fgf); Assert.Equal(4, propVals.Count); FdoPropertyValue pKey = propVals.FindItem("KEY"); FdoPropertyValue pMapkey = propVals.FindItem("MAPKEY"); FdoPropertyValue pName = propVals.FindItem("NAME"); FdoPropertyValue pGeom = propVals.FindItem("Geometry"); Assert.NotNull(pKey); Assert.NotNull(pMapkey); Assert.NotNull(pName); Assert.NotNull(pGeom); FdoStringValue key = pKey.GetValue() as FdoStringValue; FdoStringValue mapkey = pMapkey.GetValue() as FdoStringValue; FdoStringValue name = pName.GetValue() as FdoStringValue; FdoGeometryValue geomVal = pGeom.GetValue() as FdoGeometryValue; Assert.NotNull(key); Assert.NotNull(mapkey); Assert.NotNull(name); Assert.NotNull(geomVal); Assert.False(key.IsNull()); Assert.False(mapkey.IsNull()); Assert.False(name.IsNull()); Assert.False(geomVal.IsNull()); //Null values one by one propVals.SetValueNull("NAME"); Assert.False(key.IsNull()); Assert.False(mapkey.IsNull()); Assert.True(name.IsNull()); Assert.False(geomVal.IsNull()); propVals.SetValueNull("KEY"); Assert.True(key.IsNull()); Assert.False(mapkey.IsNull()); Assert.True(name.IsNull()); Assert.False(geomVal.IsNull()); propVals.SetValueNull("MAPKEY"); Assert.True(key.IsNull()); Assert.True(mapkey.IsNull()); Assert.True(name.IsNull()); Assert.False(geomVal.IsNull()); propVals.SetValueNull("Geometry"); Assert.True(key.IsNull()); Assert.True(mapkey.IsNull()); Assert.True(name.IsNull()); Assert.True(geomVal.IsNull()); //Re-set values propVals.SetStringValue("KEY", "MOC"); propVals.SetStringValue("MAPKEY", "MOC123"); propVals.SetStringValue("NAME", "My Own Country"); propVals.SetGeometryValue("Geometry", fgf); //Re-fetch data values to query null status key = pKey.GetValue() as FdoStringValue; mapkey = pMapkey.GetValue() as FdoStringValue; name = pName.GetValue() as FdoStringValue; geomVal = pGeom.GetValue() as FdoGeometryValue; Assert.NotNull(key); Assert.NotNull(mapkey); Assert.NotNull(name); Assert.NotNull(geomVal); Assert.False(key.IsNull()); Assert.False(mapkey.IsNull()); Assert.False(name.IsNull()); Assert.False(geomVal.IsNull()); } }
private void DoUpdate(FdoIConnection conn) { string geomName = null; FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); FdoFeatureClass clsDef = schemas.GetClassDefinition(null, "World_Countries") as FdoFeatureClass; Assert.NotNull(clsDef); FdoGeometricPropertyDefinition geomProp = clsDef.GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; FdoIUpdate updateCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Update) as FdoIUpdate; Assert.NotNull(updateCmd); updateCmd.SetFeatureClassName("World_Countries"); updateCmd.SetFilter("NAME = 'Canada'"); FdoFgfGeometryFactory geomFactory = FdoFgfGeometryFactory.GetInstance(); FdoPropertyValueCollection propVals = updateCmd.GetPropertyValues(); FdoStringValue nameVal = FdoStringValue.Create(); Assert.True(nameVal.IsNull()); FdoStringValue keyVal = FdoStringValue.Create(); Assert.True(keyVal.IsNull()); FdoStringValue mapkeyVal = FdoStringValue.Create(); Assert.True(mapkeyVal.IsNull()); FdoGeometryValue geomVal = FdoGeometryValue.Create(); Assert.True(geomVal.IsNull()); FdoPropertyValue pKey = FdoPropertyValue.Create("KEY", keyVal); FdoPropertyValue pMapKey = FdoPropertyValue.Create("MAPKEY", mapkeyVal); propVals.Add(pKey); propVals.Add(pMapKey); //Set the actual values keyVal.String = "MOC"; mapkeyVal.String = "MOC123"; int updated = updateCmd.Execute(); Assert.Equal(66, updated); FdoISelect selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_Select) as FdoISelect; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIFeatureReader fr = selectCmd.Execute(); while (fr.ReadNext()) { Assert.False(fr.IsNull("KEY")); Assert.False(fr.IsNull("MAPKEY")); Assert.Equal(fr.GetString("KEY"), "MOC"); Assert.Equal(fr.GetString("MAPKEY"), "MOC123"); } fr.Close(); }
private void DoFilteredSpatialExtents(FdoIConnection conn) { FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); Assert.Equal(1, schemas.Count); FdoFeatureSchema schema = schemas.GetItem(0); FdoClassCollection classes = schema.GetClasses(); string geomName = null; for (int i = 0; i < classes.Count; i++) { FdoClassDefinition cls = classes.GetItem(i); if (cls.Name == "World_Countries") { Assert.IsAssignableFrom <FdoFeatureClass>(cls); FdoGeometricPropertyDefinition geomProp = ((FdoFeatureClass)cls).GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; } } Assert.NotNull(geomName); FdoISelectAggregates selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_SelectAggregates) as FdoISelectAggregates; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); FdoIdentifierCollection propNames = selectCmd.GetPropertyNames(); FdoExpression countExpr = FdoExpression.Parse("SpatialExtents(" + geomName + ")"); FdoComputedIdentifier countIdent = FdoComputedIdentifier.Create("EXTENTS", countExpr); propNames.Add(countIdent); FdoIDataReader rdr = selectCmd.Execute(); FdoFgfGeometryFactory geomFactory = FdoFgfGeometryFactory.GetInstance(); int iterations = 0; while (rdr.ReadNext()) { Assert.False(rdr.IsNull("EXTENTS")); Assert.Equal(FdoPropertyType.FdoPropertyType_GeometricProperty, rdr.GetPropertyType("EXTENTS")); FdoByteArrayHandle bytes = rdr.GetGeometryBytes("EXTENTS"); Assert.NotNull(bytes); FdoIGeometry geom = geomFactory.CreateGeometryFromFgf(bytes); Assert.NotNull(geom); string wkt = geom.Text; Assert.NotNull(wkt); System.Diagnostics.Debug.WriteLine(string.Format("SpatialExtents() - {0}", wkt)); iterations++; } rdr.Close(); Assert.Equal(1, iterations); //Re-test with sugar methods propNames.Clear(); Assert.Equal(0, propNames.Count); propNames.AddComputedIdentifier("EXTENTS", "SpatialExtents(" + geomName + ")"); Assert.Equal(1, propNames.Count); rdr = selectCmd.Execute(); iterations = 0; while (rdr.ReadNext()) { Assert.False(rdr.IsNull("EXTENTS")); Assert.Equal(FdoPropertyType.FdoPropertyType_GeometricProperty, rdr.GetPropertyType("EXTENTS")); FdoByteArrayHandle bytes = rdr.GetGeometryBytes("EXTENTS"); Assert.NotNull(bytes); FdoIGeometry geom = geomFactory.CreateGeometryFromFgf(bytes); Assert.NotNull(geom); string wkt = geom.Text; Assert.NotNull(wkt); System.Diagnostics.Debug.WriteLine(string.Format("SpatialExtents() - {0}", wkt)); iterations++; } rdr.Close(); Assert.Equal(1, iterations); }
private static void ProcessExpressionCapabilities(FdoIConnection conn) { using (var caps = conn.GetExpressionCapabilities()) { Log("Expression Capabilities"); Log("\tFunctions:"); var funcs = caps.GetFunctions(); for (int i = 0; i < funcs.Count; i++) { var func = funcs.GetItem(i); Log("\t\t{0}", func.Name); Log("\t\t\tDescription: {0}", func.Description); Log("\t\t\tCategory: {0}", func.FunctionCategoryType); Log("\t\t\tReturnPropertyType: {0}", func.ReturnPropertyType); Log("\t\t\tReturnType: {0}", func.ReturnType); Log("\t\t\tSupportsVariableArgumentsList: {0}", func.SupportsVariableArgumentsList()); Log("\t\t\tIsAggregate: {0}", func.IsAggregate()); var args = func.GetArguments(); Log("\t\t\tArguments:"); for (int j = 0; j < args.Count; j++) { var arg = args.GetItem(j); Log("\t\t\t\tName: {0}", arg.Name); Log("\t\t\t\tDescription: {0}", arg.Description); Log("\t\t\t\tDataType: {0}", arg.DataType); Log("\t\t\t\tPropertyType: {0}", arg.PropertyType); var valueList = arg.GetArgumentValueList(); if (valueList != null) { Log("\t\t\t\tArgument Values:"); Log("\t\t\t\t\tConstraintType: {0}", valueList.ConstraintType); Log("\t\t\t\t\tConstraint List:"); var list = valueList.GetConstraintList(); for (var k = 0; k < list.Count; k++) { var item = list.GetItem(k); Log("\t\t\t\t\t\t{0}", item.ToString()); } } } var sigs = func.GetSignatures(); Log("\t\t\tSignatures:"); for (int j = 0; j < sigs.Count; j++) { Log("\t\t\t\tSIGNATURE {0}", (j + 1)); var sig = sigs.GetItem(j); Log("\t\t\t\tReturnType: {0}", sig.ReturnType); Log("\t\t\t\tReturnPropertyType: {0}", sig.ReturnPropertyType); var sigArgs = sig.GetArguments(); Log("\t\t\t\tArguments:"); for (int k = 0; k < sigArgs.Count; k++) { var arg = sigArgs.GetItem(k); Log("\t\t\t\t\tName: {0}", arg.Name); Log("\t\t\t\t\tDescription: {0}", arg.Description); Log("\t\t\t\t\tDataType: {0}", arg.DataType); Log("\t\t\t\t\tPropertyType: {0}", arg.PropertyType); var valueList = arg.GetArgumentValueList(); if (valueList != null) { Log("\t\t\t\t\tArgument Values:"); Log("\t\t\t\t\t\tConstraintType: {0}", valueList.ConstraintType); Log("\t\t\t\t\t\tConstraint List:"); var list = valueList.GetConstraintList(); for (var l = 0; l < list.Count; l++) { var item = list.GetItem(l); Log("\t\t\t\t\t\t\t{0}", item.ToString()); } } } } } Log("\tSupportedExpressionTypes:"); var exprTypes = caps.SupportedExpressionTypes(); for (int i = 0; i < exprTypes.Count; i++) { Log("\t\t{0}", exprTypes.GetItem(i)); } } }
private void DoSpatialExtents(FdoIConnection conn) { FdoIDescribeSchema desc = conn.CreateCommand((int)FdoCommandType.FdoCommandType_DescribeSchema) as FdoIDescribeSchema; Assert.NotNull(desc); FdoFeatureSchemaCollection schemas = desc.Execute(); Assert.NotNull(schemas); Assert.Equal(1, schemas.Count); FdoFeatureSchema schema = schemas.GetItem(0); FdoClassCollection classes = schema.GetClasses(); string geomName = null; for (int i = 0; i < classes.Count; i++) { FdoClassDefinition cls = classes.GetItem(i); if (cls.Name == "World_Countries") { Assert.IsAssignableFrom<FdoFeatureClass>(cls); FdoGeometricPropertyDefinition geomProp = ((FdoFeatureClass)cls).GetGeometryProperty(); Assert.NotNull(geomProp); geomName = geomProp.Name; } } Assert.NotNull(geomName); FdoISelectAggregates selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_SelectAggregates) as FdoISelectAggregates; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); FdoIdentifierCollection propNames = selectCmd.GetPropertyNames(); FdoExpression countExpr = FdoExpression.Parse("SpatialExtents(" + geomName + ")"); FdoComputedIdentifier countIdent = FdoComputedIdentifier.Create("EXTENTS", countExpr); propNames.Add(countIdent); FdoIDataReader rdr = selectCmd.Execute(); FdoFgfGeometryFactory geomFactory = FdoFgfGeometryFactory.GetInstance(); int iterations = 0; while (rdr.ReadNext()) { Assert.False(rdr.IsNull("EXTENTS")); Assert.Equal(FdoPropertyType.FdoPropertyType_GeometricProperty, rdr.GetPropertyType("EXTENTS")); FdoByteArrayHandle bytes = rdr.GetGeometryBytes("EXTENTS"); Assert.NotNull(bytes); FdoIGeometry geom = geomFactory.CreateGeometryFromFgf(bytes); Assert.NotNull(geom); string wkt = geom.Text; Assert.NotNull(wkt); System.Diagnostics.Debug.WriteLine(string.Format("SpatialExtents() - {0}", wkt)); iterations++; } rdr.Close(); Assert.Equal(1, iterations); //Re-test with sugar methods propNames.Clear(); Assert.Equal(0, propNames.Count); propNames.AddComputedIdentifier("EXTENTS", "SpatialExtents(" + geomName + ")"); Assert.Equal(1, propNames.Count); rdr = selectCmd.Execute(); iterations = 0; while (rdr.ReadNext()) { Assert.False(rdr.IsNull("EXTENTS")); Assert.Equal(FdoPropertyType.FdoPropertyType_GeometricProperty, rdr.GetPropertyType("EXTENTS")); FdoByteArrayHandle bytes = rdr.GetGeometryBytes("EXTENTS"); Assert.NotNull(bytes); FdoIGeometry geom = geomFactory.CreateGeometryFromFgf(bytes); Assert.NotNull(geom); string wkt = geom.Text; Assert.NotNull(wkt); System.Diagnostics.Debug.WriteLine(string.Format("SpatialExtents() - {0}", wkt)); iterations++; } rdr.Close(); Assert.Equal(1, iterations); }
private void DoFilteredDistinct(FdoIConnection conn) { FdoISelectAggregates selectCmd = conn.CreateCommand((int)FdoCommandType.FdoCommandType_SelectAggregates) as FdoISelectAggregates; Assert.NotNull(selectCmd); selectCmd.SetFeatureClassName("World_Countries"); selectCmd.SetFilter("NAME = 'Canada'"); selectCmd.Distinct = true; FdoIdentifierCollection propNames = selectCmd.GetPropertyNames(); FdoIdentifier ident = FdoIdentifier.Create("KEY"); propNames.Add(ident); FdoIDataReader rdr = selectCmd.Execute(); HashSet<string> values = new HashSet<string>(); int count = 0; while (rdr.ReadNext()) { values.Add(rdr.GetString("KEY")); count++; } rdr.Close(); Assert.Equal(values.Count, count); }