Hi I try to use QueryTools.GetFeaturesByColumnValue but I get an exception..... When looking in debug mode it seems that
the shapefilefeaturelayer is open but I cannot see any column....
thanks.
jm
private static ShapeFileFeatureLayer STATES;
private static ShapeFileFeatureLayer ZIP3;
private static ShapeFileFeatureLayer ZIP5;
private static ShapeFileFeatureLayer COUNTY;
private static FeatureCache featureCache_DataSource_STATES;
private static FeatureCache featureCache_DataSource_ZIP3;
private static FeatureCache featureCache_DataSource_ZIP5;
private static FeatureCache featureCache_DataSource_COUNTY;
private static Collection<Feature> _spq_ZIP5;
private static Collection<Feature> _spq_ZIP3;
private static Collection<Feature> _spq_STATES;
private static Collection<Feature> _spq_COUNTY;
public void GeoRelationshipsOpen(string SERVER_ICON_LIBRARY_DRIVE, string SERVER_RAM_DRIVE, string SERVER_RAM_DRIVE_CACHE_PATH)
{
featureCache_DataSource_STATES = new FeatureCache();
featureCache_DataSource_ZIP3 = new FeatureCache();
featureCache_DataSource_ZIP5 = new FeatureCache();
featureCache_DataSource_COUNTY = new FeatureCache();
featureCache_DataSource_STATES.IsActive = true;
featureCache_DataSource_ZIP3.IsActive = true;
featureCache_DataSource_ZIP5.IsActive = true;
featureCache_DataSource_COUNTY.IsActive = true;
ShapeFileFeatureLayer.BuildIndexFile(SERVER_RAM_DRIVE + @"\USCENSUS\US_STATES\tl_2010_us_state10.shp", BuildIndexMode.DoNotRebuild);
STATES = new ShapeFileFeatureLayer(SERVER_RAM_DRIVE + @"\USCENSUS\US_STATES\tl_2010_us_state10.shp", ShapeFileReadWriteMode.ReadOnly);
STATES.Name = "STATES";
STATES.FeatureSource.GeoCache = featureCache_DataSource_STATES;
STATES.FeatureSource.GeoCache.IsActive = true;
STATES.FeatureSource.Open();
ShapeFileFeatureLayer.BuildIndexFile(SERVER_RAM_DRIVE + @"\USCENSUS\US_ZIPCODES_3\z399_d00.shp", BuildIndexMode.DoNotRebuild);
ZIP3 = new ShapeFileFeatureLayer(SERVER_RAM_DRIVE + @"\USCENSUS\US_ZIPCODES_3\z399_d00.shp", ShapeFileReadWriteMode.ReadOnly);
ZIP3.Name = "ZIP3";
ZIP3.FeatureSource.GeoCache = featureCache_DataSource_STATES;
ZIP3.FeatureSource.GeoCache.IsActive = true;
ZIP3.FeatureSource.Open();
ShapeFileFeatureLayer.BuildIndexFile(SERVER_RAM_DRIVE + @"\USCENSUS\US_ZIPCODES_5\tl_2010_us_zcta510.shp", BuildIndexMode.DoNotRebuild);
ZIP5 = new ShapeFileFeatureLayer(SERVER_RAM_DRIVE + @"\USCENSUS\US_ZIPCODES_5\tl_2010_us_zcta510.shp", ShapeFileReadWriteMode.ReadOnly);
ZIP5.Name = "ZIP5";
ZIP5.FeatureSource.GeoCache = featureCache_DataSource_STATES;
ZIP5.FeatureSource.GeoCache.IsActive = true;
ZIP5.FeatureSource.Open();
ShapeFileFeatureLayer.BuildIndexFile(SERVER_RAM_DRIVE + @"\USCENSUS\US_COUNTY\tl_2011_us_county.shp", BuildIndexMode.DoNotRebuild);
COUNTY = new ShapeFileFeatureLayer(SERVER_RAM_DRIVE + @"\USCENSUS\US_COUNTY\tl_2011_us_county.shp", ShapeFileReadWriteMode.ReadOnly);
COUNTY.Name = "COUNTY";
COUNTY.FeatureSource.GeoCache = featureCache_DataSource_COUNTY;
COUNTY.FeatureSource.GeoCache.IsActive = true;
COUNTY.FeatureSource.Open();
}
public object GeoRelationships(string gkey, string gvalue)
{
_spq_ZIP5 = new Collection<Feature>();
_spq_ZIP3 = new Collection<Feature>();
_spq_STATES = new Collection<Feature>();
_spq_COUNTY = new Collection<Feature>();
GeoRelationShips _gr = new GeoRelationShips();
Collection<FeatureSourceColumn> _fc = ZIP5.FeatureSource.GetColumns();
_spq_ZIP5 = ZIP5.QueryTools.GetFeaturesByColumnValue(gkey, gvalue);
_spq_STATES = STATES.QueryTools.GetFeaturesContaining(_spq_ZIP5[0], ReturningColumnsType.AllColumns);
_spq_ZIP3 = ZIP3.QueryTools.GetFeaturesContaining(_spq_ZIP5[0], ReturningColumnsType.AllColumns);
_spq_COUNTY = COUNTY.QueryTools.GetFeaturesContaining(_spq_ZIP5[0], ReturningColumnsType.AllColumns);
_gr._geoid_ZIP5_WKT = _spq_ZIP5[0].GetShape().GetCenterPoint().GetWellKnownText();
_gr._geoid_STATE_WKT = _spq_STATES[0].GetShape().GetCenterPoint().GetWellKnownText();
_gr._geoid_ZIP3_WKT = _spq_ZIP3[0].GetShape().GetCenterPoint().GetWellKnownText();
_gr._geoid_COUNTY_WKT = _spq_COUNTY[0].GetShape().GetCenterPoint().GetWellKnownText();
_gr._geoid_ZIP5 = _spq_ZIP5[0].ColumnValues["GEOID10"];
_gr._geoid_ZIP3 = _spq_ZIP3[0].ColumnValues["ZCTA3"];
_gr._geoid_STATES = _spq_STATES[0].ColumnValues["GEOID10"];
_gr._geoid_COUNTY = _spq_COUNTY[0].ColumnValues["GEOID"];
return (_gr);
}
public void GeoRelationshipsClose()
{
STATES.FeatureSource.Close();
ZIP3.FeatureSource.Close();
ZIP5.FeatureSource.Close();
COUNTY.FeatureSource.Close();
}