public void MakingSymbolGeoJsonFile()
{
///////////////////////////////////////////////////////////////
//Setting current Map to access Layers, Feature Class and Features
//build string builder to write on the ImageResultfile
///////////////////////////////////////////////////////////////
string path = "";
IMap map = ArcMap.Document.FocusMap;
//GeoJson geoJson;
IEnumLayer enumLayer = map.get_Layers(null, true);
ILayer layer = enumLayer.Next();
//((IDataset)layer).Workspace.
IFeatureLayer featureLayer;
IFeature iFeature;
try
{
while (layer != null)
{
if (layer.Name == "SymbolPositiveLabel")
{
GeoJson geoJson = new GeoJson();
geoJson.featureInJson = new FeatureInJSON();
geoJson.featureInJson.displayFieldName = layer.Name;
geoJson.featureInJson.fieldAliases = new FieldAliases();
//////////////////////////Set Alias Feature of the Layer////////////////////
geoJson.featureInJson.fieldAliases.Mass_centerX = "Mass_centerX";
geoJson.featureInJson.fieldAliases.Mass_centerY = "Mass_centerY";
geoJson.featureInJson.fieldAliases.OBJECTID = "OBJECTID";
geoJson.featureInJson.fieldAliases.Orientation = "Orientation";
geoJson.featureInJson.fieldAliases.Susp_char_count = "Susp_char_count";
geoJson.featureInJson.fieldAliases.Susp_text = "Susp_text";
geoJson.featureInJson.fieldAliases.Text = "Text";
geoJson.featureInJson.fieldAliases.Char_count = "Char_count";
geoJson.featureInJson.fieldAliases.Filename = "Filename";
//////////////////////Set Fields of the current Layer///////////////////////
geoJson.featureInJson.fields = new Field_info[9];
setGeoJASONFeilds("OBJECTID", esriFieldType.esriFieldTypeOID, geoJson.featureInJson.fields[0]);
setGeoJASONFeilds("Text", esriFieldType.esriFieldTypeString, geoJson.featureInJson.fields[1]);
setGeoJASONFeilds("Char_count", esriFieldType.esriFieldTypeInteger, geoJson.featureInJson.fields[2]);
setGeoJASONFeilds("Orientation", esriFieldType.esriFieldTypeDouble, geoJson.featureInJson.fields[3]);
setGeoJASONFeilds("Filename", esriFieldType.esriFieldTypeString, geoJson.featureInJson.fields[4]);
setGeoJASONFeilds("Susp_text", esriFieldType.esriFieldTypeString, geoJson.featureInJson.fields[5]);
setGeoJASONFeilds("Susp_char_count", esriFieldType.esriFieldTypeInteger, geoJson.featureInJson.fields[6]);
setGeoJASONFeilds("Mass_centerX", esriFieldType.esriFieldTypeDouble, geoJson.featureInJson.fields[7]);
setGeoJASONFeilds("Mass_centerY", esriFieldType.esriFieldTypeDouble, geoJson.featureInJson.fields[8]);
path = _rasterInfo.rasterData + "\\PositiveLayerInfo.json";//@"C:\Emgu\emgucv-windows-universal-cuda 2.9.0.1922\Emgu.CV.Example\Strabo_Map_Processing\Hollywood\Data\PositiveLayerInfo.json"; //
featureLayer = (IFeatureLayer)layer;
int count = featureLayer.FeatureClass.FeatureCount(null);
for (int j = 1; j <= count; j++)
{
iFeature = featureLayer.FeatureClass.GetFeature(j);
geoJson.featureInJson.features.Add(new Features());
int i = j - 1;
geoJson.featureInJson.features[i].attributes = new Attributes();
geoJson.featureInJson.features[i].attributes.OBJECTID = int.Parse(iFeature.get_Value(0).ToString());
geoJson.featureInJson.features[i].geometry = new Strabo.Core.OCR.Geometry();
geoJson.featureInJson.features[i].geometry.rings[0, 0, 0] = iFeature.Extent.UpperLeft.X;
geoJson.featureInJson.features[i].geometry.rings[0, 0, 1] = iFeature.Extent.UpperLeft.Y;
geoJson.featureInJson.features[i].geometry.rings[0, 1, 0] = iFeature.Extent.UpperRight.X;
geoJson.featureInJson.features[i].geometry.rings[0, 1, 1] = iFeature.Extent.UpperRight.Y;
geoJson.featureInJson.features[i].geometry.rings[0, 2, 0] = iFeature.Extent.LowerRight.X;
geoJson.featureInJson.features[i].geometry.rings[0, 2, 1] = iFeature.Extent.LowerRight.Y;
geoJson.featureInJson.features[i].geometry.rings[0, 3, 0] = iFeature.Extent.LowerLeft.X;
geoJson.featureInJson.features[i].geometry.rings[0, 3, 1] = iFeature.Extent.LowerLeft.Y;
geoJson.featureInJson.features[i].geometry.rings[0, 4, 0] = iFeature.Extent.UpperLeft.X;
geoJson.featureInJson.features[i].geometry.rings[0, 4, 1] = iFeature.Extent.UpperLeft.Y;
if (iFeature.Extent.UpperLeft.Y < 0 && _rasterInfo.ratserNegative > 0)
_rasterInfo.ratserNegative = -1;
}
geoJson.writeJsonFile(path);
}
layer = enumLayer.Next();
}
}
catch (Exception e)
{
Log.WriteLine(e.Message);
}
}