第一次提交。完成基本功能。
This commit is contained in:
commit
089e2f670f
|
|
@ -0,0 +1,5 @@
|
|||
bin
|
||||
Packages
|
||||
Windows API Code Pack 1.1
|
||||
obj
|
||||
Windows API Code Pack 1.1.zip
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImgGPS2KML", "ImgGPS2KML\ImgGPS2KML.csproj", "{1494F446-2E9D-4A5B-86B8-F0C140AE0169}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1494F446-2E9D-4A5B-86B8-F0C140AE0169}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Binary file not shown.
|
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.21022</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{1494F446-2E9D-4A5B-86B8-F0C140AE0169}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ImgGPS2KML</RootNamespace>
|
||||
<AssemblyName>ImgGPS2KML</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="ExifLib, Version=1.7.0.0, Culture=neutral, PublicKeyToken=30284005913968db, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Packages\ExifLib\lib\net20\ExifLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Windows API Code Pack 1.1\binaries\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>Windows API Code Pack 1.1\binaries\Microsoft.WindowsAPICodePack.Shell.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainWin.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWin.Designer.cs">
|
||||
<DependentUpon>MainWin.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="MainWin.resx">
|
||||
<DependentUpon>MainWin.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
namespace ImgGPS2KML
|
||||
{
|
||||
partial class MainWin
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.btAddDirectory = new System.Windows.Forms.Button();
|
||||
this.btExportKML = new System.Windows.Forms.Button();
|
||||
this.dvDirectory = new System.Windows.Forms.DataGridView();
|
||||
this.directory = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.coordination = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.canExport = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.individuallyWritenBy杜孟远20207ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dvDirectory)).BeginInit();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btAddDirectory
|
||||
//
|
||||
this.btAddDirectory.Location = new System.Drawing.Point(675, 27);
|
||||
this.btAddDirectory.Name = "btAddDirectory";
|
||||
this.btAddDirectory.Size = new System.Drawing.Size(112, 23);
|
||||
this.btAddDirectory.TabIndex = 0;
|
||||
this.btAddDirectory.Text = "添加目录";
|
||||
this.btAddDirectory.UseVisualStyleBackColor = true;
|
||||
this.btAddDirectory.Click += new System.EventHandler(this.bt_add_directory);
|
||||
//
|
||||
// btExportKML
|
||||
//
|
||||
this.btExportKML.Location = new System.Drawing.Point(675, 82);
|
||||
this.btExportKML.Name = "btExportKML";
|
||||
this.btExportKML.Size = new System.Drawing.Size(112, 23);
|
||||
this.btExportKML.TabIndex = 2;
|
||||
this.btExportKML.Text = "导出kml";
|
||||
this.btExportKML.UseVisualStyleBackColor = true;
|
||||
this.btExportKML.Click += new System.EventHandler(this.btExportKML_Click);
|
||||
//
|
||||
// dvDirectory
|
||||
//
|
||||
this.dvDirectory.AllowUserToAddRows = false;
|
||||
this.dvDirectory.AllowUserToDeleteRows = false;
|
||||
this.dvDirectory.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dvDirectory.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.directory,
|
||||
this.coordination,
|
||||
this.canExport});
|
||||
this.dvDirectory.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
|
||||
this.dvDirectory.Location = new System.Drawing.Point(12, 27);
|
||||
this.dvDirectory.Name = "dvDirectory";
|
||||
this.dvDirectory.RowTemplate.Height = 23;
|
||||
this.dvDirectory.Size = new System.Drawing.Size(657, 492);
|
||||
this.dvDirectory.TabIndex = 3;
|
||||
//
|
||||
// directory
|
||||
//
|
||||
this.directory.HeaderText = "文件夹";
|
||||
this.directory.Name = "directory";
|
||||
this.directory.Width = 450;
|
||||
//
|
||||
// coordination
|
||||
//
|
||||
this.coordination.HeaderText = "标签中心坐标";
|
||||
this.coordination.Name = "coordination";
|
||||
//
|
||||
// canExport
|
||||
//
|
||||
this.canExport.HeaderText = "可导出";
|
||||
this.canExport.Name = "canExport";
|
||||
this.canExport.TrueValue = "1";
|
||||
this.canExport.Width = 50;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.aboutToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(820, 25);
|
||||
this.menuStrip1.TabIndex = 4;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// aboutToolStripMenuItem
|
||||
//
|
||||
this.aboutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.individuallyWritenBy杜孟远20207ToolStripMenuItem});
|
||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(55, 21);
|
||||
this.aboutToolStripMenuItem.Text = "About";
|
||||
//
|
||||
// individuallyWritenBy杜孟远20207ToolStripMenuItem
|
||||
//
|
||||
this.individuallyWritenBy杜孟远20207ToolStripMenuItem.Name = "individuallyWritenBy杜孟远20207ToolStripMenuItem";
|
||||
this.individuallyWritenBy杜孟远20207ToolStripMenuItem.Size = new System.Drawing.Size(283, 22);
|
||||
this.individuallyWritenBy杜孟远20207ToolStripMenuItem.Text = "Individually Writen By 杜孟远 2020.7";
|
||||
//
|
||||
// MainWin
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(820, 562);
|
||||
this.Controls.Add(this.dvDirectory);
|
||||
this.Controls.Add(this.btExportKML);
|
||||
this.Controls.Add(this.btAddDirectory);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "MainWin";
|
||||
this.Text = "ImgGPS2KML";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dvDirectory)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btAddDirectory;
|
||||
private System.Windows.Forms.Button btExportKML;
|
||||
private System.Windows.Forms.DataGridView dvDirectory;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn directory;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn coordination;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn canExport;
|
||||
private System.Windows.Forms.MenuStrip menuStrip1;
|
||||
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem individuallyWritenBy杜孟远20207ToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Diagnostics;
|
||||
using ExifLib;
|
||||
using System.Xml;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using System.IO;
|
||||
namespace ImgGPS2KML
|
||||
{
|
||||
public partial class MainWin : Form
|
||||
{
|
||||
public MainWin()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void putPlacemark(XmlTextWriter writer,string name, double longitude, double latitude)
|
||||
{
|
||||
writer.WriteStartElement("Placemark");
|
||||
writer.WriteStartElement("name");
|
||||
writer.WriteString(name);
|
||||
writer.WriteEndElement();//end of name
|
||||
writer.WriteStartElement("Style");
|
||||
writer.WriteStartElement("IconStyle");
|
||||
writer.WriteStartElement("Icon");
|
||||
writer.WriteStartElement("href");
|
||||
writer.WriteString("http://maps.google.com/mapfiles/kml/paddle/blu-blank.png");
|
||||
writer.WriteEndElement();//end of href
|
||||
writer.WriteEndElement();//end of Icon
|
||||
writer.WriteStartElement("color");
|
||||
writer.WriteString("ffffffff");
|
||||
writer.WriteEndElement();//end of color
|
||||
writer.WriteStartElement("scale");
|
||||
writer.WriteString("1.0");
|
||||
writer.WriteEndElement();//end of scale
|
||||
writer.WriteEndElement();//end of IconStyle
|
||||
writer.WriteEndElement();//end of Style
|
||||
writer.WriteStartElement("Point");
|
||||
writer.WriteStartElement("coordinates");
|
||||
writer.WriteString(String.Format("{0},{1},0", longitude, latitude));
|
||||
writer.WriteEndElement();//end of coordinates
|
||||
writer.WriteEndElement();//end of Point
|
||||
writer.WriteEndElement();//end of Placemark
|
||||
}
|
||||
|
||||
private double toDecimalUnit(double degree, double minute, double second)//把2度2分3秒这样的数据转换成2.3212这样的数据。
|
||||
{
|
||||
return degree + minute / 60 + second / 3600;
|
||||
}
|
||||
|
||||
//private double distanceByLongNLat(double long1, double lat1, double long2, double lat2)//计算经纬度两点间距离
|
||||
//{
|
||||
// double a, b, R;
|
||||
// R = 6378137;//地球半径
|
||||
// lat1 = lat1 * Math.PI / 180.0;
|
||||
// lat2 = lat2 * Math.PI / 180.0;
|
||||
// a = lat1 - lat2;
|
||||
// b = (long1 - long2) * Math.PI / 180.0;
|
||||
// double d;
|
||||
// double sa2, sb2;
|
||||
// sa2 = Math.sin(a / 2.0);
|
||||
// sb2 = Math.sin(b / 2.0);
|
||||
// d = 2 * R * Math.asin(Math.sqrt(sa2 * sa2 + Math.cos(lat1) * Math.cos(lat2) * sb2 * sb2));
|
||||
// return d;
|
||||
//}
|
||||
|
||||
private List<double[]> extractCordinattionFromImg(List<string> imgPaths)//获得所有图片的坐标
|
||||
{
|
||||
List<double[]> longitudNLatitude = new List<double[]>();//第一个是经度,第二个是纬度
|
||||
foreach (string path in imgPaths)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (ExifReader reader = new ExifReader(path))
|
||||
{
|
||||
double[] longitude;//经度
|
||||
double[] latitude;//纬度
|
||||
reader.GetTagValue<double[]>(ExifTags.GPSLongitude, out longitude);
|
||||
reader.GetTagValue<double[]>(ExifTags.GPSLatitude, out latitude);
|
||||
if (longitude == null || latitude == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
double decimalLongtitude;
|
||||
decimalLongtitude = toDecimalUnit(longitude[0], longitude[1], longitude[2]);
|
||||
double decimalLatitude;
|
||||
decimalLatitude = toDecimalUnit(latitude[0], latitude[1], latitude[2]);
|
||||
longitudNLatitude.Add(new double[] { decimalLongtitude, decimalLatitude });
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return longitudNLatitude;
|
||||
|
||||
}
|
||||
|
||||
double[] get_centroid(List<double[]> cluster)
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
int coord_num = cluster.Count;
|
||||
foreach (double[] coord in cluster)
|
||||
{
|
||||
double lon = coord[0] / 180 * Math.PI;
|
||||
double lat = coord[1] / 180 * Math.PI;
|
||||
x += Math.Cos(lat) * Math.Cos(lon);
|
||||
y += Math.Cos(lat) * Math.Sin(lon);
|
||||
z += Math.Sin(lat);
|
||||
}
|
||||
x /= coord_num;
|
||||
y /= coord_num;
|
||||
z /= coord_num;
|
||||
return new double[] { Math.Atan2(y, x) * 180 / Math.PI, Math.Atan2(z, Math.Sqrt(x * x + y * y)) * 180 / Math.PI };
|
||||
}
|
||||
|
||||
private List<string> searchJPG(string sourceDir)
|
||||
{
|
||||
string[] allFiles = Directory.GetFiles(sourceDir);
|
||||
List<string> jpgFiles = new List<string>();
|
||||
foreach (string file in allFiles)
|
||||
{
|
||||
if (Path.GetExtension(file).ToLower() == ".jpg")
|
||||
{
|
||||
jpgFiles.Add(file);
|
||||
}
|
||||
}
|
||||
return jpgFiles;
|
||||
|
||||
}
|
||||
|
||||
private void bt_add_directory(object sender, EventArgs e)
|
||||
{
|
||||
this.dvDirectory.Rows.Clear();
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
|
||||
dialog.Multiselect = true;
|
||||
dialog.IsFolderPicker = true;
|
||||
if (dialog.ShowDialog() == CommonFileDialogResult.Ok)
|
||||
{
|
||||
foreach (String selectDir in dialog.FileNames)
|
||||
{
|
||||
string coordination_col_text;
|
||||
bool canExport;
|
||||
canExport = true;
|
||||
List<string> imgPaths = searchJPG(selectDir);
|
||||
if (imgPaths.Count > 0)
|
||||
{
|
||||
List<double[]> coordinationOfImg;
|
||||
coordinationOfImg = extractCordinattionFromImg(imgPaths);
|
||||
if (coordinationOfImg.Count > 0)
|
||||
{
|
||||
double[] centroid;
|
||||
centroid = get_centroid(coordinationOfImg);//计算所有图片坐标的中心
|
||||
coordination_col_text = string.Format("{0},{1}", centroid[0], centroid[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
coordination_col_text = "图片中未找到坐标。";
|
||||
canExport = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
coordination_col_text="未找到图片。";
|
||||
canExport = false;
|
||||
}
|
||||
this.dvDirectory.Rows.Add(new object[]{selectDir,coordination_col_text,canExport});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btExportKML_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveFileDialog dialog = new SaveFileDialog();
|
||||
dialog.Filter = "kml file (*.kml)|*.kml";
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
using (XmlTextWriter writer = new XmlTextWriter(dialog.FileName, Encoding.UTF8))
|
||||
{
|
||||
writer.Formatting = Formatting.Indented;
|
||||
writer.WriteStartDocument();
|
||||
writer.WriteStartElement("kml");
|
||||
writer.WriteStartAttribute("xmlns");
|
||||
writer.WriteString("http://www.opengis.net/kml/2.2");
|
||||
writer.WriteEndAttribute();
|
||||
writer.WriteStartAttribute("xmlns:gx");
|
||||
writer.WriteString("http://www.google.com/kml/ext/2.2");
|
||||
writer.WriteEndAttribute();
|
||||
writer.WriteStartAttribute("xmlns:atom");
|
||||
writer.WriteString("http://www.w3.org/2005/Atom");
|
||||
writer.WriteEndAttribute();
|
||||
writer.WriteStartElement("Document");
|
||||
writer.WriteStartElement("name");
|
||||
writer.WriteString("照片导出坐标");
|
||||
writer.WriteEndElement();//end of name
|
||||
foreach (DataGridViewRow row in this.dvDirectory.Rows)
|
||||
{
|
||||
Int32 canExport;
|
||||
DataGridViewCheckBoxCell checkBoxColum=row.Cells[2] as DataGridViewCheckBoxCell;
|
||||
canExport =Convert.ToInt32(checkBoxColum.Value);
|
||||
if (canExport !=1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
double longitude;
|
||||
double latitude;
|
||||
string name;
|
||||
name = Path.GetFileName(Convert.ToString(row.Cells[0].Value));
|
||||
longitude = Convert.ToDouble(Convert.ToString(row.Cells[1].Value).Split(',')[0]);
|
||||
latitude = Convert.ToDouble(Convert.ToString(row.Cells[1].Value).Split(',')[1]);
|
||||
putPlacemark(writer, name, longitude, latitude);
|
||||
}
|
||||
writer.WriteEndElement();//end of Document
|
||||
writer.WriteEndElement();//end of xml
|
||||
writer.WriteEndDocument();
|
||||
|
||||
}
|
||||
MessageBox.Show("已导出");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="directory.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="coordination.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="canExport.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="directory.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="coordination.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="canExport.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ImgGPS2KML
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainWin());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ImgGPS2KML")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("ImgGPS2KML")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("cf014ee2-c398-4d20-a317-4d89b74c3842")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.8689
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ImgGPS2KML.Properties
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ImgGPS2KML.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.8689
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ImgGPS2KML.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
Loading…
Reference in New Issue