Rose,
As I am understanding this problem, following codes shows you how to only fetch data only the first time:
//Create your own cached data featureSource.
public class CustomPostgreFeatureSource : PostgreSqlFeatureSource
{
private bool isDataFetched;
private Collection<Feature> cachedFeatures;
public bool IsDataFetched
{
get { return isDataFetched; }
}
public CustomPostgreFeatureSource()
: this(string.Empty, string.Empty, string.Empty)
{ }
public CustomPostgreFeatureSource(string connectionString, string tableName, string featureIdColumn)
: this(connectionString, tableName, featureIdColumn, -999)
{
}
public CustomPostgreFeatureSource(string connectionString, string tableName, string featureIdColumn, int srid)
: base(connectionString,tableName,featureIdColumn,srid)
{
isDataFetched = false;
}
public CustomPostgreFeatureSource(NpgsqlConnection connection, string tableName, string featureIdColumn)
: this(connection, tableName, featureIdColumn, -999)
{
}
public CustomPostgreFeatureSource(NpgsqlConnection connection, string tableName, string featureIdColumn, int srid)
: base(connection,tableName,featureIdColumn,srid)
{
isDataFetched = false;
}
protected override Collection<Feature> GetFeaturesInsideBoundingBoxCore(RectangleShape boundingBox, IEnumerable<string> returningColumnNames)
{
if (!isDataFetched)
{
cachedFeatures = base.GetAllFeatures(ReturningColumnsType.AllColumns);
isDataFetched = true;
}
return cachedFeatures;
}
}
//Create your own featureLayer.
public class CustomPostgreFeatureLayer : PostgreSqlFeatureLayer
{
public CustomPostgreFeatureLayer()
: this(string.Empty, string.Empty, string.Empty, -999)
{ }
public CustomPostgreFeatureLayer(string connectionString, string tableName, string featureIdColumn)
: this(connectionString, tableName, featureIdColumn, -999)
{
}
public CustomPostgreFeatureLayer(string connectionString, string tableName, string featureIdColumn, int srid)
: base()
{
FeatureSource = new CustomPostgreFeatureSource(connectionString, tableName, featureIdColumn, srid);
SetupTools();
}
public CustomPostgreFeatureLayer(NpgsqlConnection connection, string tableName, string featureIdeColumn)
: this(connection, tableName, featureIdeColumn, -999)
{
}
public CustomPostgreFeatureLayer(NpgsqlConnection connection, string tableName, string featureIdeColumn, int srid)
: base()
{
FeatureSource = new CustomPostgreFeatureSource(connection, tableName, featureIdeColumn, srid);
SetupTools();
}
}
//Useage.
CustomPostgreFeatureLayer postgreLayer = new CustomPostgreFeatureLayer(connectString, "rail", "oid");//fllkaa40
postgreLayer.CommandTimeout = 6000;
postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.Railway1;
postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
Any more qustions just feel free to let me know.
Thanks.
Yale