Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #66

Merged
merged 2 commits into from
Jan 8, 2015
Merged

Dev #66

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
completed diff file load optimization, updated strings for gp tool an…
…d remove the automatic edit extension for the osm file loader
  • Loading branch information
ThomasEmge committed Jan 8, 2015
commit bee29f1ef1aa33c2f8ab8cfd1ccd65784ced3012
4 changes: 2 additions & 2 deletions src/OSMClassExtension/OSMClassExtensionStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="OSMClassExtension_FeatureInspector_pointnumber_exceeeded_in_ring" xml:space="preserve">
<value>The existing number of vertices exceeds the allowed number of {0} in the ring index {1}.</value>
Expand Down
23 changes: 18 additions & 5 deletions src/OSMClassExtension/OSMUtility.cs
Original file line number Diff line number Diff line change
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 @@ -1226,14 +1226,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 +1249,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 @@ -1324,6 +1329,7 @@ public bool DoesHaveKeys(relation currentrelation)
public bool DoesHaveKeys(way currentway)
{
bool doesHaveKeys = false;
bool partsOverride = false;

try
{
Expand All @@ -1343,12 +1349,19 @@ public bool DoesHaveKeys(way currentway)
else if (waytag.k.ToLower().Equals("note"))
{
}
else if (waytag.k.ToLower().Contains("building:part"))
{
partsOverride = true;
}
else
{
doesHaveKeys = true;
break;
}
}

// the building:part key sets the flag be a supporting elements, hence the trigger override
if (partsOverride)
doesHaveKeys = false;
}
}
catch (Exception ex)
Expand Down
3,218 changes: 2,171 additions & 1,047 deletions src/OSMGeoProcessing/OSMGPDiffLoader.cs

Large diffs are not rendered by default.

38 changes: 21 additions & 17 deletions src/OSMGeoProcessing/OSMGPFileLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -964,23 +964,27 @@ public void Execute(ESRI.ArcGIS.esriSystem.IArray paramvalues, ESRI.ArcGIS.esriS
{
try
{
if (osmPointFeatureClass != null)
{
osmPointFeatureClass.ApplyOSMClassExtension();
ComReleaser.ReleaseCOMObject(osmPointFeatureClass);
}

if (osmLineFeatureClass != null)
{
osmLineFeatureClass.ApplyOSMClassExtension();
ComReleaser.ReleaseCOMObject(osmLineFeatureClass);
}

if (osmPolygonFeatureClass != null)
{
osmPolygonFeatureClass.ApplyOSMClassExtension();
ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
}
// TE -- 1/7/2015
// this is a 'breaking' change as the default loader won't no longer enable the edit extension
// the reasoning here is that most users would like the OSM in a 'read-only' fashion, and don't need to track
// changes to be properly transmitted back to the OSM server
//if (osmPointFeatureClass != null)
//{
// osmPointFeatureClass.ApplyOSMClassExtension();
// ComReleaser.ReleaseCOMObject(osmPointFeatureClass);
//}

//if (osmLineFeatureClass != null)
//{
// osmLineFeatureClass.ApplyOSMClassExtension();
// ComReleaser.ReleaseCOMObject(osmLineFeatureClass);
//}

//if (osmPolygonFeatureClass != null)
//{
// osmPolygonFeatureClass.ApplyOSMClassExtension();
// ComReleaser.ReleaseCOMObject(osmPolygonFeatureClass);
//}

osmToolHelper = null;

Expand Down
21 changes: 21 additions & 0 deletions src/OSMGeoProcessing/OSMGPToolsStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -840,4 +840,25 @@
<data name="GPTools_OSMGPUpload_password" xml:space="preserve">
<value>Password</value>
</data>
<data name="GPTools_OSMGPDiffLoader_createmodify_message" xml:space="preserve">
<value>{0} {1} considered for creation or update.</value>
</data>
<data name="GPTools_OSMGPDiffLoader_delete_message" xml:space="preserve">
<value>{0} {1} considered for deletion.</value>
</data>
<data name="GPTools_OSM_nodes" xml:space="preserve">
<value>nodes</value>
</data>
<data name="GPTools_OSM_ways" xml:space="preserve">
<value>ways</value>
</data>
<data name="GPTools_OSM_relations" xml:space="preserve">
<value>relations</value>
</data>
<data name="GPTools_OSM_superrelations" xml:space="preserve">
<value>super-relations</value>
</data>
<data name="GPTools_OSMGPDiffLoader_loadtime_message" xml:space="preserve">
<value>The diff loaded in {0} minutes.</value>
</data>
</root>
10 changes: 9 additions & 1 deletion src/OSMGeoProcessing/OSMGPToolsStrings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,12 @@ GPTools_Utility_WayLoadError=General error in the way loading routine ({0}).
GPTools_Utility_RelationLoadError=General error in the relation loading routine ({0}).
# 2.2
GPTools_OSMGPUpload_username=User name
GPTools_OSMGPUpload_password=Password
GPTools_OSMGPUpload_password=Password
# 2.3
GPTools_OSMGPDiffLoader_createmodify_message={0} {1} considered for creation or update.
GPTools_OSMGPDiffLoader_delete_message={0} {1} considered for deletion.
GPTools_OSM_nodes=nodes
GPTools_OSM_ways=ways
GPTools_OSM_relations=relations
GPTools_OSM_superrelations=super-relations
GPTools_OSMGPDiffLoader_loadtime_message=The diff loaded in {0} minutes.
80 changes: 72 additions & 8 deletions src/OSMGeoProcessing/OSMToolHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ internal void loadOSMNodes(string osmFileLocation, ref ITrackCancel TrackCancel,
pointFeature.set_Value(osmPointIDFieldIndex, currentNode.id);

string isSupportingNode = "";
if (_osmUtility.DoesHaveKeys(currentNode))
if (_osmUtility.DoesHaveKeys(currentNode.tag))
{
// if case it has tags I assume that the node presents an entity of it own,
// hence it is not a supporting node in the context of supporting a way or relation
Expand Down Expand Up @@ -2702,27 +2702,27 @@ internal List<string> loadOSMWays(string osmFileLocation, ref ITrackCancel Track
{
if (osmSupportingElementPolylineFieldIndex > -1)
{
if (currentWay.tag == null)
if (_osmUtility.DoesHaveKeys(currentWay))
{
featureLineBuffer.set_Value(osmSupportingElementPolylineFieldIndex, "yes");
featureLineBuffer.set_Value(osmSupportingElementPolylineFieldIndex, "no");
}
else
{
featureLineBuffer.set_Value(osmSupportingElementPolylineFieldIndex, "no");
featureLineBuffer.set_Value(osmSupportingElementPolylineFieldIndex, "yes");
}
}
}
else
{
if (osmSupportingElementPolygonFieldIndex > -1)
{
if (currentWay.tag == null)
if (_osmUtility.DoesHaveKeys(currentWay))
{
featurePolygonBuffer.set_Value(osmSupportingElementPolygonFieldIndex, "yes");
featurePolygonBuffer.set_Value(osmSupportingElementPolygonFieldIndex, "no");
}
else
{
featurePolygonBuffer.set_Value(osmSupportingElementPolygonFieldIndex, "no");
featurePolygonBuffer.set_Value(osmSupportingElementPolygonFieldIndex, "yes");
}
}
}
Expand Down Expand Up @@ -3669,7 +3669,7 @@ internal List<string> loadOSMRelations(string osmFileLocation, ref ITrackCancel
// add it to the new geometry and mark the added geometry as a supporting element
relationPolygonGeometryCollection.AddSegmentCollection((ISegmentCollection)ringCollection.get_Geometry(0));

// TE - 10/14/2014
// TE - 10/14/2014 ( 1/5/2015 -- still under consideration)
// the initial assessment if the feature is a supporting element based on the existence of tags
// has been made, at this point I don't think there is a reason to reassess the nature of feature
// based on its appearance in a relation
Expand Down Expand Up @@ -4490,6 +4490,70 @@ public static bool IsThisWayALine(way currentway)
return isALine;
}

// split to osm element ids into manageable chunks of db requests
internal List<string> SplitOSMIDRequests<T>(List<T> osmElements, int extensionVersion) where T : class
{
List<string> osmIDRequests = new List<string>();

if (osmElements == null)
return osmIDRequests;

if (osmElements.Count == 0)
return osmIDRequests;

try
{
StringBuilder newQueryString = new StringBuilder();
newQueryString.Append("(");

foreach (T currentElement in osmElements)
{
string elementID = String.Empty;
if (currentElement is node)
elementID = (currentElement as node).id;
else if (currentElement is way)
elementID = (currentElement as way).id;
else if (currentElement is relation)
elementID = (currentElement as relation).id;

if (extensionVersion == 1)
newQueryString.Append(elementID + ",");
else if (extensionVersion == 2)
{
newQueryString.Append("'");
newQueryString.Append(elementID);
newQueryString.Append("'");
newQueryString.Append(",");
}

// not too sure about this hard coded length of 6500
// since the SQL implementation is data source dependent
if (newQueryString.Length > 6500)
{
newQueryString = newQueryString.Remove(newQueryString.Length - 1, 1);

newQueryString.Append(")");
osmIDRequests.Add(newQueryString.ToString());

newQueryString = new StringBuilder();
newQueryString.Append("(");
}
}

if (newQueryString.Length > 2)
{
newQueryString = newQueryString.Remove(newQueryString.Length - 1, 1);
newQueryString.Append(")");
osmIDRequests.Add(newQueryString.ToString());
}
}
catch
{
}

return osmIDRequests;
}

// split to node ids into manageable chunks of db requests
internal List<string> SplitOSMIDRequests(ESRI.ArcGIS.OSM.OSMClassExtension.way currentway, int extensionVersion)
{
Expand Down
Binary file modified src/data/OpenStreetMap Toolbox.tbx
Binary file not shown.