Skip to content

Commit

Permalink
Merge pull request #78 from Esri/dev
Browse files Browse the repository at this point in the history
Merge dev codebase to support ArcGIS Desktop 10.3 to master
  • Loading branch information
eggwhites committed Mar 16, 2015
2 parents 308e829 + df25dad commit 6038468
Show file tree
Hide file tree
Showing 54 changed files with 4,213 additions and 1,765 deletions.
30 changes: 10 additions & 20 deletions README.md
@@ -1,29 +1,21 @@
# arcgis-osm-editor

ArcGIS Editor for OpenStreetMap - Welcome!

ArcGIS Editor for OpenStreetMap is a toolset for GIS users to access and contribute to OpenStreetMap through their ArcGIS Desktop or Server environment. Learn more at [the ArcGIS Editor for OSM wiki page](https://github.com/Esri/arcgis-osm-editor/wiki).
ArcGIS Editor for OpenStreetMap - Welcome
ArcGIS Editor for OpenStreetMap is a toolset for GIS users to access and contribute to OpenStreetMap through their Desktop or Server environment. Learn more [here](http://www.esri.com/osmeditor).

## Features
* Download data from OSM into a file geodatabase - get data from the current extent or load from an .osm file
* Download data from OSM into a file geodatabase - download from current extent or load from .osm file
* Create your own planet (.osm) files
* Edit OSM data in ArcGIS
* Upload edits back to OSM
* Create routing networks from OSM data
* Create custom feature services based on OSM data

## Download Instructions
1. You can download the ArcGIS Editor for OSM Desktop setup from arcgis.com at the following links:
a) [ArcGIS Editor for OpenStreetMap, 10.2 and 10.2.1] (http://www.arcgis.com/home/item.html?id=16970017f81349548d0a9eead0ebba39)
b) [ArcGIS Editor for OpenStreetMap, 10.1] (http://www.arcgis.com/home/item.html?id=6a2a3c3cece749558393d4e80241ef51)
c) [ArcGIS Editor for OpenStreetMap, 10.0] (http://www.arcgis.com/home/item.html?id=620e5a4c4e3d4125aed3f66110870257)

## Instructions
1. Compiled setups (if you just want to install in ArcGIS and not deal with the code) can be downloaded from ArcGIS Online. For the 10.3 installer, download from here http://www.arcgis.com/home/item.html?id=75716d933f1c40a784243198e0dc11a1.

2. Once downloaded, install as described in the http://github.com/Esri/arcgis-osm-editor/wiki/System-requirements%2C-installation%2C-%26-working-with-the-code documentation.

3. Read documentation at http://github.com/Esri/arcgis-osm-editor/wiki/Documentation on how to use the tools
2. Read documentation at http://github.com/Esri/arcgis-osm-editor/wiki/Documentation on how to use the tools

4. If you want to work with the code:
3. If you want to work with the code:

a) Fork and then clone the repo.

Expand All @@ -39,14 +31,12 @@ c) [ArcGIS Editor for OpenStreetMap, 10.0] (http://www.arcgis.com/home/item.html
## Requirements

* An OpenStreetMap login (create at https://www.openstreetmap.org/user/new)
* ArcGIS for Desktop 10.1 (Desktop Component)
* ArcGIS Server 10.1, ArcSDE 10.1, and IIS (Server Component)
* ArcGIS for Desktop 10.3
* Visual Studio 2010 (if you're working with the code)

## Resources

* [OpenStreetMap](http://www.openstreetmap.org)
* [OpenStreetMap wiki] (http://wiki.openstreetmap.org/wiki/ArcGIS_Editor_for_OSM)

## Issues

Expand All @@ -57,7 +47,7 @@ Find a bug or want to request a new feature? Please let us know by submitting a
Anyone and everyone is welcome to contribute.

## Licensing
Copyright 2012 Esri
Copyright 2015 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -74,4 +64,4 @@ limitations under the License.
A copy of the license is available in the repository's [license.txt]( https://github.com/Esri/arcgis-osm-editor/blob/master/license.txt) file.

[](Esri Tags: ArcGIS Editor OpenStreetMap)
[](Esri Language: C-Sharp)
[](Esri Language: C-Sharp)
27 changes: 27 additions & 0 deletions src/OSMClassExtension/OSMClassExtensionManager.cs
Expand Up @@ -118,10 +118,37 @@ public static string WhereClauseByExtensionVersion(this ITable table, object osm
{
whereClause = table.SqlIdentifier(fieldName) + " = '" + Convert.ToString(osmID) + "'";
}
else
{
whereClause = table.SqlIdentifier(fieldName) + " = '" + Convert.ToString(osmID) + "'";
}

return whereClause;
}

/// <summary>
/// Returns an array of field names for fields that have the 'required' flag.
/// </summary>
/// <returns>Returns an array of field names for fields that have the 'required' flag.
/// If no required fields are found, or the table is null an empty array is returned.</returns>
public static string[] ExtractRequiredFields(this IFeatureClass table)
{
List<string> requiredFields = new List<string>();

if (table == null)
return requiredFields.ToArray();

for (int fieldIndex = 0; fieldIndex < table.Fields.FieldCount; fieldIndex++)
{
if (table.Fields.get_Field(fieldIndex).Required == true)
{
requiredFields.Add(table.Fields.get_Field(fieldIndex).Name);
}
}

return requiredFields.ToArray();
}


/// <summary>
/// Formulates the WhereClause for the QueryFilter based on the version of the extension
Expand Down
109 changes: 88 additions & 21 deletions src/OSMClassExtension/OSMUtility.cs
Expand Up @@ -92,7 +92,7 @@ public void insertOSMDocumentIntoCollection(osm osmDocument, Dictionary<string,
}
}

public void insertMembers(int osmMembersRelationFieldIndex, IRow insertRow, member[] relationMembers)
public void insertMembers(int osmMembersRelationFieldIndex, ref IRow insertRow, member[] relationMembers)
{
if (insertRow.Fields.get_Field(osmMembersRelationFieldIndex).Type == esriFieldType.esriFieldTypeBlob)
{
Expand Down Expand Up @@ -1168,6 +1168,62 @@ public Byte[] StringToUTF8ByteArray(String pXmlString)
return isMemberOfDictionary;
}

/// <summary>
/// Compare the list of tags und the given feature to see if they are same. Only relevant tags are compared.
/// Non-relevant tags are "created_by", "source", "attribution", "version", "note", "type".
/// </summary>
/// <param name="relationTags"></param>
/// <param name="row"></param>
/// <param name="tagFieldIndex"></param>
/// <param name="currentWorkspace"></param>
/// <returns>Boolean indicating if the relevant tags are the same.</returns>
public bool AreTagsTheSame(IList<tag> relationTags, IRow row, int tagFieldIndex, IWorkspace currentWorkspace)
{
bool tagsAreTheSame = true;

try
{
IList<tag> relevantRelationTags = RetrieveRelevantTags(relationTags);

tag[] wayTags = retrieveOSMTags(row, tagFieldIndex, currentWorkspace);

IList<tag> relevantWayTags = RetrieveRelevantTags(new List<tag>(wayTags));

if (relevantWayTags.Count != relevantRelationTags.Count)
{
tagsAreTheSame = false;
return tagsAreTheSame;
}

foreach (var wayTag in relevantWayTags)
{
if (!relevantRelationTags.Contains(wayTag, new TagKeyValueComparer()))
{
tagsAreTheSame = false;
return tagsAreTheSame;
}
}
}
catch { }

return tagsAreTheSame;
}

private IList<tag> RetrieveRelevantTags(IList<tag> originalTags)
{
IList<tag> relevantTags = new List<tag>();

string[] non_relevant = {"created_by", "source", "attribution", "note", "version", "type"};

foreach (var currentTag in originalTags)
{
if (!System.Array.Exists(non_relevant, str => str.ToLower().Equals(currentTag.k)))
relevantTags.Add(currentTag);
}

return relevantTags;
}

/// <summary>
/// Given a row object from a feature class determines if valid tags exist.
/// </summary>
Expand Down Expand Up @@ -1226,14 +1282,16 @@ public bool DoesHaveKeys(IRow row, int tagFieldIndex, IWorkspace currentWorkspac
/// </summary>
/// <param name="currentnode">OpenStreetMap node object to be examined. Non-relevant tags are 'created_by', 'source', 'attribution', and 'note'. </param>
/// <returns>Boolean indicating if the node has relevant tags or not.</returns>
public bool DoesHaveKeys(node currentnode)
public bool DoesHaveKeys(tag[] tags)
{
bool doesHaveKeys = false;
bool partsOverride = false;

try
{
if (currentnode.tag != null)
if (tags != null)
{
foreach (tag nodetag in currentnode.tag)
foreach (tag nodetag in tags)
{
if (nodetag.k.ToLower().Equals("created_by"))
{
Expand All @@ -1247,6 +1305,9 @@ public bool DoesHaveKeys(node currentnode)
else if (nodetag.k.ToLower().Equals("note"))
{
}
else if (nodetag.k.ToLower().Contains("building:part"))
{
}
else
{
doesHaveKeys = true;
Expand Down Expand Up @@ -1323,30 +1384,36 @@ public bool DoesHaveKeys(relation currentrelation)
/// <returns>Boolean indicating if the way has relevant tags or not.</returns>
public bool DoesHaveKeys(way currentway)
{
IList<tag> relevantTags = new List<tag>();
bool doesHaveKeys = false;

try
{
if (currentway.tag != null)
string[] non_relevant = { "created_by", "source", "attribution", "note", "version", "type" };

foreach (var currentTag in currentway.tag)
{
foreach (tag waytag in currentway.tag)
if (!System.Array.Exists(non_relevant, str => str.ToLower().Equals(currentTag.k)))
relevantTags.Add(currentTag);
}

if (relevantTags.Count > 0)
{
doesHaveKeys = true;

foreach (var wayTag in relevantTags)
{
if (waytag.k.ToLower().Equals("created_by"))
{
}
else if (waytag.k.ToLower().Equals("source"))
{
}
else if (waytag.k.ToLower().Equals("attribution"))
{
}
else if (waytag.k.ToLower().Equals("note"))
if (wayTag.k.ToLower().Contains("building:part"))
{
}
else
{
doesHaveKeys = true;
break;
doesHaveKeys = false;

// the exception is the existence of both building:part and building,
// then building will take precedence
if (relevantTags.Contains(new tag() { k = "building" }, new TagKeyComparer()))
{
doesHaveKeys = true;
break;
}
}
}
}
Expand Down

0 comments on commit 6038468

Please sign in to comment.