Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #643 from Esri/dev
Browse files Browse the repository at this point in the history
January 2019 release
  • Loading branch information
kgonzago authored Jan 25, 2019
2 parents 504d585 + 5a103ba commit 136ec8b
Show file tree
Hide file tree
Showing 49 changed files with 2,399 additions and 14,681 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@
<ItemGroup>
<AddInContent Include="Images\distance-direction-16.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Data\Circles.lyr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\Ellipses.lyr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\Lines.lyr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Data\Rings.lyr">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<ZipFileExtension>esriAddIn</ZipFileExtension>
<AddInTargetProduct>Desktop</AddInTargetProduct>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace ArcMapAddinDistanceAndDirection.Models
{
class FeatureClassUtils
{
private IGxDialog m_ipSaveAsGxDialog = null;
private IGxDialog m_ipSaveAsGxDialog = null;

/// <summary>
/// Prompts the user to save features
Expand Down Expand Up @@ -76,7 +76,7 @@ public string PromptUserWithGxDialog(int iParentWindow)
IGxObject ipGxObject = m_ipSaveAsGxDialog.FinalLocation;
string nameString = m_ipSaveAsGxDialog.Name;
bool replacingObject = m_ipSaveAsGxDialog.ReplacingObject;
string path = m_ipSaveAsGxDialog.FinalLocation.FullName +
string path = m_ipSaveAsGxDialog.FinalLocation.FullName +
System.IO.Path.DirectorySeparatorChar + m_ipSaveAsGxDialog.Name;
IGxObject ipSelectedObject = m_ipSaveAsGxDialog.InternalCatalog.SelectedObject;

Expand All @@ -96,7 +96,7 @@ public string PromptUserWithGxDialog(int iParentWindow)
{
if (System.Windows.Forms.MessageBox.Show("You've selected a feature class that already exists. Do you wish to replace it?", "Overwrite Feature Class", System.Windows.Forms.MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
{
return m_ipSaveAsGxDialog.FinalLocation.FullName +
return m_ipSaveAsGxDialog.FinalLocation.FullName +
System.IO.Path.DirectorySeparatorChar + m_ipSaveAsGxDialog.Name;
}

Expand All @@ -112,7 +112,7 @@ public string PromptUserWithGxDialog(int iParentWindow)
}
}

return m_ipSaveAsGxDialog.FinalLocation.FullName +
return m_ipSaveAsGxDialog.FinalLocation.FullName +
System.IO.Path.DirectorySeparatorChar + m_ipSaveAsGxDialog.Name;
}
else
Expand Down Expand Up @@ -160,7 +160,7 @@ public IFeatureClass CreateFCOutput(string outputPath, SaveAsType saveAsType, Li
feature.Shape = PolylineToPolygon(graphic.Geometry);
else
feature.Shape = graphic.Geometry;

switch (graphic.GraphicType.ToString())
{
case "Line":
Expand Down Expand Up @@ -247,7 +247,7 @@ public IFeatureClass CreateFCOutput(string outputPath, SaveAsType saveAsType, Li
}
case "RangeRing":
{

System.Object rings;
System.Object distance;
System.Object distunit;
Expand Down Expand Up @@ -278,7 +278,7 @@ public IFeatureClass CreateFCOutput(string outputPath, SaveAsType saveAsType, Li
{
DeleteShapeFile(outputPath);
}

fc = ExportToShapefile(outputPath, graphicsList, ipSpatialRef, isGraphicLineOrRangeRing);
}
return fc;
Expand Down Expand Up @@ -358,7 +358,7 @@ private IFeatureClass ExportToShapefile(string fileNamePath, List<Graphic> graph
fieldsEdit = (IFieldsEdit)fields;
IField field = null;
IFieldEdit fieldEdit = null;
field = new FieldClass();
field = new FieldClass();
fieldEdit = (IFieldEdit)field;
fieldEdit.Name_2 = "Shape";
fieldEdit.Type_2 = (esriFieldType.esriFieldTypeGeometry);
Expand All @@ -371,7 +371,7 @@ private IFeatureClass ExportToShapefile(string fileNamePath, List<Graphic> graph
geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
else
geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;

geomDefEdit.SpatialReference_2 = ipSpatialRef;

fieldEdit.GeometryDef_2 = geomDef;
Expand Down Expand Up @@ -694,7 +694,7 @@ private IFeatureClass ExportToShapefile(string fileNamePath, List<Graphic> graph
featurelayer = new FeatureLayerClass();
featurelayer.FeatureClass = featClass;
featurelayer.Name = featClass.AliasName;

System.Runtime.InteropServices.Marshal.FinalReleaseComObject(workspace);
workspace = null;
GC.Collect();
Expand All @@ -708,7 +708,7 @@ private IFeatureClass ExportToShapefile(string fileNamePath, List<Graphic> graph
}
}
}

/// <summary>
/// Determines if selected feature class already exists
/// </summary>
Expand Down Expand Up @@ -765,7 +765,7 @@ private void DeleteFeatureClass(IFeatureWorkspace fWorkspace, string fcName)
/// <param name="graphicsList">Graphics List</param>
/// <param name="polyLineFC">Is Polyline FC</param>
/// <returns>IFeatureClass</returns>
private IFeatureClass CreateFeatureClass(IFeatureWorkspace featWorkspace, string name, List<Graphic> graphicsList, bool polyLineFC)
public IFeatureClass CreateFeatureClass(IFeatureWorkspace featWorkspace, string name, List<Graphic> graphicsList, bool polyLineFC)
{
string graphicsType = graphicsList[0].GraphicType.ToString();
IFieldsEdit pFldsEdt = new FieldsClass();
Expand Down Expand Up @@ -973,7 +973,7 @@ private IFeatureClass CreateFeatureClass(IFeatureWorkspace featWorkspace, string
/// </summary>
/// <param name="geom">IGeometry</param>
/// <returns>IPolygon</returns>
private IPolygon PolylineToPolygon(IGeometry geom)
public static IPolygon PolylineToPolygon(IGeometry geom)
{
//Build a polygon segment-by-segment.
IPolygon polygon = new PolygonClass();
Expand All @@ -995,5 +995,5 @@ private IPolygon PolylineToPolygon(IGeometry geom)

return polygon;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,39 @@
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.Display;
using DistanceAndDirectionLibrary;

namespace ArcMapAddinDistanceAndDirection.Models
{
class KMLUtils
{

public bool ConvertLayerToKML(string kmzOutputPath, string tmpShapefilePath, ESRI.ArcGIS.Carto.IMap map)

public bool ConvertLayerToKML(string kmzOutputPath, string tmpShapefilePath,
ESRI.ArcGIS.Carto.IMap map, GraphicTypes graphicType)
{
try
{
string kmzName = System.IO.Path.GetFileName(kmzOutputPath);

IGeoProcessor2 gp = new GeoProcessorClass();
gp.OverwriteOutput = true;
IGeoFeatureLayer geoLayer = null;

IVariantArray parameters = new VarArrayClass();
parameters.Add(tmpShapefilePath);
parameters.Add(kmzName);
gp.Execute("MakeFeatureLayer_management", parameters, null);

string layerFileName = getLayerFileFromGraphicType(graphicType);
if (!string.IsNullOrEmpty(layerFileName))
{
IVariantArray parametersASM = new VarArrayClass();
parametersASM.Add(kmzName);
parametersASM.Add(layerFileName);
gp.Execute("ApplySymbologyFromLayer_management", parametersASM, null);
}

IVariantArray parameters1 = new VarArrayClass();
// assign parameters
parameters1.Add(kmzName);
Expand All @@ -58,6 +71,10 @@ public bool ConvertLayerToKML(string kmzOutputPath, string tmpShapefilePath, ESR
break;
}
}
if (geoLayer != null)
{
map.DeleteLayer(geoLayer);
}

return true;
}
Expand All @@ -67,7 +84,42 @@ public bool ConvertLayerToKML(string kmzOutputPath, string tmpShapefilePath, ESR
return false;
}
}

private string getLayerFileFromGraphicType(GraphicTypes graphicType)
{
var asm = System.Reflection.Assembly.GetExecutingAssembly();
string addinPath = System.IO.Path.GetDirectoryName(
Uri.UnescapeDataString(
new Uri(asm.CodeBase).LocalPath));

string layerFileName = string.Empty;

switch (graphicType)
{
case GraphicTypes.Line:
layerFileName = "Lines.lyr";
break;
case GraphicTypes.RangeRing:
layerFileName = "Rings.lyr";
break;
case GraphicTypes.Circle:
layerFileName = "Circles.lyr";
break;
case GraphicTypes.Ellipse:
layerFileName = "Ellipses.lyr";
break;
default:
break;
}

if (string.IsNullOrEmpty(layerFileName))
return layerFileName;

string layerPath = System.IO.Path.Combine(addinPath, "Data", layerFileName);

return layerPath;
}

}


}
Loading

0 comments on commit 136ec8b

Please sign in to comment.