private void FillCoordinateNodesForWays(DataTable nodesRefsAndWays) { using (SqlConnection connection = new SqlConnection(_connectionString)) { using (SqlCommand command = new SqlCommand("dbo.GetNodesForWays", connection)) { command.CommandType = CommandType.StoredProcedure; SqlParameter geoTable = new SqlParameter("ways", nodesRefsAndWays); command.Parameters.Add(geoTable); // ----- DEBUG Helpers.Log.Log.Write("Start download data nodes for ways - " + " (" + _waysOsm.Count + ")"); // ------ connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Node node = _nodesRefs[(Int64)reader["id"]]; var lat = (double)reader["lat"]; var lon = (double)reader["lon"]; node.Latitude = (double)reader["lat"]; node.Longtitude = (double)reader["lon"]; } // ----- DEBUG Helpers.Log.Log.Write("End download data nodes for ways - " + " (" + _waysOsm.Count + ")"); // ------ } } }
private void AddNode(Node node) { _nodesOsm.Add(node); if (_nodesOsm.Count == COUNT_ROW) { ImportPrimitiveNodesToDb(); } }
private void AddGeoNodeToTable(Node node) { DataRow dataRow = _geos.NewRow(); dataRow["idGeo"] = node.Id; dataRow["bin"] = GeoProcessing.GeoProcessingNode(node); dataRow["typeGeo"] = (byte)GeoTypeOGC.Point; this.AddRowsToGeoTable(dataRow); }
/// <summary> /// Added new NodeSimple in _nodesRefs and getting this /// </summary> /// <param name="idNodeInWay"></param> /// <returns></returns> private Node AddNodeSimpleToNodesRefs(Int64 idNodeInWay) { Node nodeSimple; if (_nodesRefs.TryGetValue(idNodeInWay, out nodeSimple)) { return(nodeSimple); } else { nodeSimple = new Node(idNodeInWay); _nodesRefs.Add(idNodeInWay, nodeSimple); return(nodeSimple); } }
/// <summary> /// Imports Nodes in Sql Server /// </summary> private void ImportPrimitiveNodesToDb() { for (int i = 0; i < _nodesOsm.Count; i++) { DataRow rowNode = _tableNodes.NewRow(); Node nodeSelect = _nodesOsm[i]; rowNode["id"] = nodeSelect.Id; rowNode["lat"] = nodeSelect.Latitude; rowNode["lon"] = nodeSelect.Longtitude; rowNode["times"] = nodeSelect.DateStamp; _tableNodes.Rows.Add(rowNode); if (_nodesOsm[i].GeoType != null) { AddGeoNodeToTable(nodeSelect); } } this.ImportDataTableInDb(ref _tableNodes, TablesTemplates.GetTableNodes); _nodesOsm.Clear(); }
/// <summary> /// Reads and parses a dense nodes (DenseNodes) /// </summary> /// <param name="denseNodes">Dense nodes to parse</param> /// <param name="latOffset">Offset latitude = .000000001 * primitiveBlock.lat_offset</param> /// <param name="lonOffset">Longitude offset = .000000001 * primitiveBlock.lon_offset</param> /// <param name="granularity">Granularity = .000000001 * primitiveBlock.granularity</param> private void ReadDenseNodes(PrimitiveBlock primitiveBlock, DenseNodes denseNodes, double latOffset, double lonOffset, double granularity) { int l = 0; long deltaid = 0; long deltalat = 0; long deltalon = 0; long deltatimestamp = 0; long deltachangeset = 0; long deltauid = 0; long deltauser_sid = 0; int dateGranularity = primitiveBlock.date_granularity; string key; string val; int hashTag; int hashValue; int idKey; int idValue; TypeValueTag typeValueTag; // Is it possible to import on the basis of the presence of significant tags bool IsImportToDb; for (int k = 0; k < denseNodes.id.Count; k++) { int has_tags = 0; deltaid += denseNodes.id[k]; deltalat += denseNodes.lat[k]; deltalon += denseNodes.lon[k]; DateTime stamp = new DateTime(); if (denseNodes.denseinfo != null) { DenseInfo denseinfo = denseNodes.denseinfo; deltatimestamp += denseinfo.timestamp[k]; //deltachangeset += denseinfo.changeset[k]; //deltauid += denseinfo.uid[k]; //deltauser_sid += denseinfo.user_sid[k]; stamp = this.timeEpoche.AddSeconds(deltatimestamp * dateGranularity / 1000); } Node node = new Node(deltaid, latOffset + (deltalat * granularity), lonOffset + (deltalon * granularity), stamp); IsImportToDb = false; if (l < denseNodes.keys_vals.Count) { while (denseNodes.keys_vals[l] != 0 && l < denseNodes.keys_vals.Count) { if (has_tags < 1) { has_tags++; } key = UTF8Encoding.UTF8.GetString( primitiveBlock.stringtable.s[denseNodes.keys_vals[l]]); val = UTF8Encoding.UTF8.GetString( primitiveBlock.stringtable.s[denseNodes.keys_vals[l + 1]]); OsmRepository.TagsRepository.AddTag(key, val, out idKey, out idValue, out typeValueTag); if (typeValueTag != TypeValueTag.NoImport) { IsImportToDb = true; this.InsertTagsAndValue(node.Id, idKey, idValue, val, typeValueTag); } l += 2; } l += 1; } // Check whether there is a tags of an object if (IsImportToDb) { node.GeoType = new GeoType(GeoTypeOGC.Point); //_nodesOsm.Add(node.Id, node); this.AddNode(node); } else { //_nodesOsm.Add(node.Id, node); this.AddNode(node); } } }
/// <summary> /// Reads and parses a dense nodes (DenseNodes) /// </summary> /// <param name="denseNodes">Dense nodes to parse</param> /// <param name="latOffset">Offset latitude = .000000001 * primitiveBlock.lat_offset</param> /// <param name="lonOffset">Longitude offset = .000000001 * primitiveBlock.lon_offset</param> /// <param name="granularity">Granularity = .000000001 * primitiveBlock.granularity</param> private void ReadDenseNodes(PrimitiveBlock primitiveBlock, DenseNodes denseNodes, double latOffset, double lonOffset, double granularity) { int l = 0; long deltaid = 0; long deltalat = 0; long deltalon = 0; long deltatimestamp = 0; long deltachangeset = 0; long deltauid = 0; long deltauser_sid = 0; int dateGranularity = primitiveBlock.date_granularity; string key; string val; int hashTag; int hashValue; int idKey; int idValue; TypeValueTag typeValueTag; // Is it possible to import on the basis of the presence of significant tags bool IsImportToDb; for (int k = 0; k < denseNodes.id.Count; k++) { int has_tags = 0; deltaid += denseNodes.id[k]; deltalat += denseNodes.lat[k]; deltalon += denseNodes.lon[k]; DateTime stamp = new DateTime(); if (denseNodes.denseinfo != null) { DenseInfo denseinfo = denseNodes.denseinfo; deltatimestamp += denseinfo.timestamp[k]; //deltachangeset += denseinfo.changeset[k]; //deltauid += denseinfo.uid[k]; //deltauser_sid += denseinfo.user_sid[k]; stamp = this.timeEpoche.AddSeconds(deltatimestamp * dateGranularity / 1000); } Node node = new Node(deltaid, latOffset + (deltalat * granularity), lonOffset + (deltalon * granularity), stamp); IsImportToDb = false; if (l < denseNodes.keys_vals.Count) { while (denseNodes.keys_vals[l] != 0 && l < denseNodes.keys_vals.Count) { if (has_tags < 1) { has_tags++; } key = UTF8Encoding.UTF8.GetString( primitiveBlock.stringtable.s[denseNodes.keys_vals[l]]); val = UTF8Encoding.UTF8.GetString( primitiveBlock.stringtable.s[denseNodes.keys_vals[l + 1]]); OsmRepository.TagsRepository.AddTag(key, val, out idKey, out idValue, out typeValueTag); if (typeValueTag != TypeValueTag.NoImport) { IsImportToDb = true; this.InsertTagsAndValue(node.Id, idKey, idValue, val, typeValueTag); } l += 2; } l += 1; } // Check whether there is a tags of an object if (IsImportToDb) { node.GeoType = new GeoType(GeoTypeOGC.Point); //_nodesOsm.Add(node.Id, node); this.AddNode(node); } else { //_nodesOsm.Add(node.Id, node); this.AddNode(node); } } }
/// <summary> /// Added new NodeSimple in _nodesRefs and getting this /// </summary> /// <param name="idNodeInWay"></param> /// <returns></returns> private Node AddNodeSimpleToNodesRefs(Int64 idNodeInWay) { Node nodeSimple; if (_nodesRefs.TryGetValue(idNodeInWay, out nodeSimple)) { return nodeSimple; } else { nodeSimple = new Node(idNodeInWay); _nodesRefs.Add(idNodeInWay, nodeSimple); return nodeSimple; } }
private void AddNode(Node node) { _nodesOsm.Add(node); if (_nodesOsm.Count == COUNT_ROW) { ImportPrimitiveNodesToDb(); } }
private void AddGeoNodeToTable(Node node) { DataRow dataRow = _geos.NewRow(); dataRow["idGeo"] = node.Id; dataRow["bin"] = GeoProcessing.GeoProcessingNode(node); dataRow["typeGeo"] = (byte)GeoTypeOGC.Point; this.AddRowsToGeoTable(dataRow); }