Beispiel #1
0
        public void RelationDelete(Relation relation)
        {
            if (this._current_changeset == null)
            {
                throw new InvalidOperationException("No open changeset found!");
            }
            if (!relation.Id.HasValue)
            {
                throw new ArgumentOutOfRangeException("Cannot update an object without an id!");
            }
            relation relation1 = relation.ConvertTo();

            relation1.changeset          = this._current_changeset.id;
            relation1.changesetSpecified = true;
            osm osm1 = new osm();

            osm1.relation    = new relation[1];
            osm1.relation[0] = relation1;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(osm));
            MemoryStream  memoryStream  = new MemoryStream();
            Stream        stream1       = (Stream)memoryStream;
            Stream        stream2       = stream1;
            osm           osm2          = osm1;

            xmlSerializer.Serialize(stream2, (object)osm2);
            stream1.Flush();
            memoryStream.Flush();
            byte[] array = memoryStream.ToArray();
            this.DoApiCall(1 != 0, string.Format("api/0.6/relation/{0}", (object)relation.Id.Value), APIConnection.Method.DELETE, array);
        }
Beispiel #2
0
        public void WayUpdate(Way way)
        {
            if (this._current_changeset == null)
            {
                throw new InvalidOperationException("No open changeset found!");
            }
            if (!way.Id.HasValue)
            {
                throw new ArgumentOutOfRangeException("Cannot update an object without an id!");
            }
            way way1 = way.ConvertTo();

            way1.changeset          = this._current_changeset.id;
            way1.changesetSpecified = true;
            osm osm1 = new osm();

            osm1.way    = new way[1];
            osm1.way[0] = way1;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(osm));
            MemoryStream  memoryStream  = new MemoryStream();
            Stream        stream1       = (Stream)memoryStream;
            Stream        stream2       = stream1;
            osm           osm2          = osm1;

            xmlSerializer.Serialize(stream2, (object)osm2);
            stream1.Flush();
            memoryStream.Flush();
            byte[] array = memoryStream.ToArray();
            this.DoApiCall(1 != 0, string.Format("api/0.6/way/{0}", (object)way.Id.Value), APIConnection.Method.PUT, array);
        }
Beispiel #3
0
        public Relation RelationCreate(Relation relation)
        {
            if (this._current_changeset == null)
            {
                throw new InvalidOperationException("No open changeset found!");
            }
            relation relation1 = relation.ConvertTo();

            relation1.changeset          = this._current_changeset.id;
            relation1.changesetSpecified = true;
            osm osm1 = new osm();

            osm1.relation    = new relation[1];
            osm1.relation[0] = relation1;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(osm));
            MemoryStream  memoryStream  = new MemoryStream();
            Stream        stream1       = (Stream)memoryStream;
            Stream        stream2       = stream1;
            osm           osm2          = osm1;

            xmlSerializer.Serialize(stream2, (object)osm2);
            stream1.Flush();
            memoryStream.Flush();
            string s = this.DoApiCall(true, "api/0.6/relation/create", APIConnection.Method.PUT, memoryStream.ToArray());
            long   result;

            if (!long.TryParse(s, out result))
            {
                throw new APIException(string.Format("Invalid response when creating a new relation: {0}", (object)s));
            }
            relation.Id = new long?(result);
            return(relation);
        }
Beispiel #4
0
        public long ChangeSetOpen(string comment, string created_by)
        {
            if (created_by == null || created_by.Length == 0)
            {
                throw new ArgumentOutOfRangeException("A created by tag always has to exist and have a usefull value.");
            }
            osm osm1 = new osm();

            osm1.changeset = new changeset[1];
            changeset changeset = new changeset();

            changeset.tag      = new tag[1];
            changeset.tag[0]   = new tag();
            changeset.tag[0].k = "created_by";
            changeset.tag[0].v = created_by;
            osm1.changeset[0]  = changeset;
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(osm));
            MemoryStream  memoryStream  = new MemoryStream();
            Stream        stream1       = (Stream)memoryStream;
            Stream        stream2       = stream1;
            osm           osm2          = osm1;

            xmlSerializer.Serialize(stream2, (object)osm2);
            stream1.Flush();
            memoryStream.Flush();
            string s = this.DoApiCall(true, "api/0.6/changeset/create", APIConnection.Method.PUT, memoryStream.ToArray());

            this._current_changeset    = changeset;
            this._current_changeset.id = long.Parse(s);
            return(this._current_changeset.id);
        }
Beispiel #5
0
        public List <OsmGeo> BoundingBoxGet(GeoCoordinateBox box)
        {
            string s = this.DoApiCall(0 != 0, string.Format("/api/0.6/map?bbox={0},{1},{2},{3}", (object)box.MinLon.ToString((IFormatProvider)CultureInfo.InvariantCulture), (object)box.MinLat.ToString((IFormatProvider)CultureInfo.InvariantCulture), (object)box.MaxLon.ToString((IFormatProvider)CultureInfo.InvariantCulture), (object)box.MaxLat.ToString((IFormatProvider)CultureInfo.InvariantCulture)), APIConnection.Method.GET, (byte[])null);

            if (s == null || s.Trim().Length <= 0)
            {
                return((List <OsmGeo>)null);
            }
            OsmDocument   osmDocument = new OsmDocument((IXmlSource) new XmlReaderSource(XmlReader.Create((TextReader) new StringReader(s))));
            List <OsmGeo> osmGeoList  = new List <OsmGeo>();
            osm           osm         = osmDocument.Osm as osm;

            if (osm.node != null)
            {
                foreach (node xml_node in osm.node)
                {
                    osmGeoList.Add((OsmGeo)this.Convertv6XmlNode(xml_node));
                }
            }
            if (osm.way != null)
            {
                foreach (way xml_way in osm.way)
                {
                    osmGeoList.Add((OsmGeo)this.Convertv6XmlWay(xml_way));
                }
            }
            if (osm.relation != null)
            {
                foreach (relation xml_relation in osm.relation)
                {
                    osmGeoList.Add((OsmGeo)this.Convertv6XmlRelation(xml_relation));
                }
            }
            return(osmGeoList);
        }
Beispiel #6
0
 static public void SaveFile(osm osmData, string osmFileName)
 {
     using (FileStream stream = File.Open(osmFileName, FileMode.Create))
     {
         XmlSerializer serializer = new XmlSerializer(typeof(osm));
         serializer.Serialize(stream, osmData);
     }
 }
Beispiel #7
0
    // Use this for initialization
    void Start()
    {
        osm mapObject = loadMapFromXML();

        Debug.Log(mapObject.note);
        MapData = new OpenStreatMap(mapObject);
        Debug.Log(MapData.Nodes.Count);
        Debug.Log(MapData.Ways.Count);
        Debug.Log(MapData.Buildings.Count);
        Debug.Log(MapData.Parks.Count);
        Debug.Log(MapData.Waters.Count);
    }
Beispiel #8
0
 public OpenStreatMap(osm osmSchema)
 {
     Nodes     = new Dictionary <ulong, Node> ();
     Ways      = new Dictionary <ulong, Shape> ();
     Buildings = new Dictionary <ulong, Building> ();
     Parks     = new Dictionary <ulong, Shape> ();
     Waters    = new Dictionary <ulong, Shape> ();
     foreach (osmNode dirtyNode in osmSchema.node)
     {
         Node node = new Node(dirtyNode);
         Nodes.Add(node.Id, node);
     }
     foreach (osmWay dirtyWay in osmSchema.way)
     {
         if (dirtyWay.tag != null)
         {
             foreach (tag dirtyTag in dirtyWay.tag)
             {
                 if (dirtyTag.k.Equals("highway"))
                 {
                     Shape way = new Shape(dirtyWay, Nodes);
                     Ways.Add(way.Id, way);
                 }
                 else if (dirtyTag.k.Equals("building") && dirtyTag.v.Equals("yes"))
                 {
                     Building building = new Building(dirtyWay, Nodes);
                     Buildings.Add(building.Id, building);
                 }
                 else if (dirtyTag.k.Equals("leisure") && dirtyTag.v.Equals("park"))
                 {
                     Shape park = new Shape(dirtyWay, Nodes);
                     Parks.Add(park.Id, park);
                 }
                 else if (dirtyTag.k.Equals("natural") && dirtyTag.v.Equals("water"))
                 {
                     Shape water = new Shape(dirtyWay, Nodes);
                     Waters.Add(water.Id, water);
                 }
             }
         }
     }
 }
Beispiel #9
0
        public osm GetMap(double bottomLeftLng, double bottomLeftLat, double topRightLng, double topRightLat)
        {
            WebClient webClient = new WebClient();

            UriBuilder requestUrl = new UriBuilder(GetCommandUrl("map"));

            requestUrl.Query = String.Format(System.Globalization.CultureInfo.InvariantCulture,
                                             "bbox={0},{1},{2},{3}", bottomLeftLng, bottomLeftLat, topRightLng, topRightLat);

            byte[] data = webClient.DownloadData(requestUrl.Uri);

            osm map = null;

            using (MemoryStream stream = new MemoryStream(data))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(osm));
                map = (osm)serializer.Deserialize(stream);
            }

            return(map);
        }
Beispiel #10
0
        private List <OsmGeo> Deserialize(string deserialized)
        {
            if (deserialized == null || deserialized.Trim().Length <= 0)
            {
                return((List <OsmGeo>)null);
            }
            OsmDocument osmDocument = new OsmDocument((IXmlSource) new XmlReaderSource(XmlReader.Create((TextReader) new StringReader(deserialized), new XmlReaderSettings()
            {
                DtdProcessing = DtdProcessing.Parse
            })));
            List <OsmGeo> list = new List <OsmGeo>();
            osm           osm  = osmDocument.Osm as osm;

            if (osm.node != null)
            {
                foreach (node xml_node in osm.node)
                {
                    list.Add((OsmGeo)this.Convertv6XmlNode(xml_node));
                }
            }
            if (osm.way != null)
            {
                foreach (way xml_way in osm.way)
                {
                    list.Add((OsmGeo)this.Convertv6XmlWay(xml_way));
                }
            }
            if (osm.relation != null)
            {
                foreach (relation xml_relation in osm.relation)
                {
                    list.Add((OsmGeo)this.Convertv6XmlRelation(xml_relation));
                }
            }
            return(list);
        }
Beispiel #11
0
        public void InitilizeOSM2OdModule()
        {
            Console.WriteLine("[*] Welcome to OSM2OD converter\n Please insert valid path to OSM XML schema:\n >> ");
            string osmFilePath = Path.GetFullPath(@"C:\vORLESUNGEN\Studienarbeit\map (3).osm");//Console.ReadLine();

            Console.WriteLine("File Path Valid, Analysing the file .... ");
            osm osmResult = null;

            XmlSerializer serializer = new XmlSerializer(typeof(osm));

            using (FileStream fileStream = new FileStream(osmFilePath, FileMode.Open))
            {
                osmResult = (osm)serializer.Deserialize(fileStream);
                Console.WriteLine("File is being Analysed .... ");
            }

            this.converterHandler = new Osm2OdConverter();
            if (osmResult != null)
            {
                converterHandler.OsmModel = osmResult;
                this.originPoint          = converterHandler.calculateBounds();
                this.waysNodesDict        = converterHandler.convertRoads();
            }
        }
Beispiel #12
0
        public void ImportData(osm osmData)
        {
            foreach (osmNode originalNode in osmData.Node)
            {
                OsmObjectAction objectAction = ParseOsmObjectAction(originalNode.Action);
                if (objectAction == OsmObjectAction.Delete)
                {
                    continue;
                }

                OsmNode node = new OsmNode(originalNode.Id, originalNode.Lat, originalNode.Lon);
                if (originalNode.Timestamp != null)
                {
                    node.Timestamp = DateTime.Parse(originalNode.Timestamp, CultureInfo.InvariantCulture);
                }
                node.User        = OsmUser.Fetch(originalNode.User, originalNode.Uid);
                node.ChangesetId = originalNode.Changeset;
                node.Visible     = originalNode.Visible;
                node.Action      = objectAction;

                foreach (tag tag in originalNode.Tag)
                {
                    node.SetTag(tag.K, tag.V);
                }

                AddNode(node);
            }

            foreach (osmWay originalWay in osmData.Way)
            {
                OsmObjectAction objectAction = ParseOsmObjectAction(originalWay.Action);
                if (objectAction == OsmObjectAction.Delete)
                {
                    continue;
                }

                OsmWay way = new OsmWay(originalWay.Id);
                if (originalWay.Timestamp != null)
                {
                    way.Timestamp = DateTime.Parse(originalWay.Timestamp, CultureInfo.InvariantCulture);
                }
                way.User        = OsmUser.Fetch(originalWay.User, originalWay.Uid);
                way.ChangesetId = originalWay.Changeset;
                way.Visible     = originalWay.Visible;
                way.Action      = objectAction;

                foreach (osmWayND nd in originalWay.Nd)
                {
                    way.AddNode(nd.Ref);
                }

                foreach (tag tag in originalWay.Tag)
                {
                    way.SetTag(tag.K, tag.V);
                }

                AddWay(way);
            }

            foreach (osmRelation originalRelation in osmData.Relation)
            {
                OsmObjectAction objectAction = ParseOsmObjectAction(originalRelation.Action);
                if (objectAction == OsmObjectAction.Delete)
                {
                    continue;
                }

                if (originalRelation.Action == "delete")
                {
                    continue;
                }

                OsmRelation relation = new OsmRelation(originalRelation.Id);
                if (originalRelation.Timestamp != null)
                {
                    relation.Timestamp = DateTime.Parse(originalRelation.Timestamp, CultureInfo.InvariantCulture);
                }
                relation.User        = OsmUser.Fetch(originalRelation.User, originalRelation.Uid);
                relation.ChangesetId = originalRelation.Changeset;
                relation.Visible     = originalRelation.Visible;
                relation.Action      = objectAction;

                foreach (osmRelationMember member in originalRelation.Member)
                {
                    OsmReferenceType referenceType = ParseOsmReferenceType(member.Type);
                    relation.AddMember(referenceType, member.Ref, member.Role);
                }

                foreach (tag tag in originalRelation.Tag)
                {
                    relation.SetTag(tag.K, tag.V);
                }

                AddRelation(relation);
            }
        }
Beispiel #13
0
        public osm ExportData(string generator)
        {
            osm osmData = new osm();

            osmData.Version = "0.6";
            osmData.Upload  = false;
            if (String.IsNullOrEmpty(generator))
            {
                osmData.Generator = "OsmUtils";
            }
            else
            {
                osmData.Generator = generator;
            }

            osmData.Node     = new List <osmNode> ();
            osmData.Way      = new List <osmWay> ();
            osmData.Relation = new List <osmRelation> ();

            foreach (OsmNode node in nodes.Values)
            {
                osmNode exportedNode = new osmNode();
                exportedNode.Id        = node.ObjectId;
                exportedNode.Lat       = node.Latitude;
                exportedNode.Lon       = node.Longitude;
                exportedNode.Timestamp = node.Timestamp.ToString("o", CultureInfo.InvariantCulture);
                exportedNode.User      = node.User.Name;
                exportedNode.Uid       = node.User.Id;
                exportedNode.Visible   = node.Visible;
                exportedNode.Action    = FormatOsmObjectAction(node.Action);
                exportedNode.Version   = 1;
                exportedNode.Changeset = node.ChangesetId;

                // Do explicity set the Lat- / LonSpecified properties.
                // Otherwise the lat / lon XML attributes would not get written, if the node has
                // a latitude or longitude of exactly 0°.
                exportedNode.LatSpecified = true;
                exportedNode.LonSpecified = true;

                exportedNode.Tag = new List <tag> ();
                foreach (OsmTag tag in node.EnumerateTags())
                {
                    exportedNode.Tag.Add(new tag(tag.Key, tag.Value));
                }

                osmData.Node.Add(exportedNode);
            }

            foreach (OsmWay way in ways.Values)
            {
                osmWay exportedWay = new osmWay();
                exportedWay.Id        = way.ObjectId;
                exportedWay.Timestamp = way.Timestamp.ToString("o", CultureInfo.InvariantCulture);
                exportedWay.User      = way.User.Name;
                exportedWay.Uid       = way.User.Id;
                exportedWay.Visible   = way.Visible;
                exportedWay.Action    = FormatOsmObjectAction(way.Action);
                exportedWay.Version   = 1;
                exportedWay.Changeset = way.ChangesetId;

                exportedWay.Nd = new List <osmWayND> ();
                foreach (long nodeId in way.EnumerateNodesIds())
                {
                    osmWayND wayNode = new osmWayND();
                    wayNode.Ref = nodeId;
                    exportedWay.Nd.Add(wayNode);
                }

                exportedWay.Tag = new List <tag> ();
                foreach (OsmTag tag in way.EnumerateTags())
                {
                    exportedWay.Tag.Add(new tag(tag.Key, tag.Value));
                }

                osmData.Way.Add(exportedWay);
            }

            foreach (OsmRelation relation in relations.Values)
            {
                osmRelation exportedRelation = new osmRelation();
                exportedRelation.Id        = relation.ObjectId;
                exportedRelation.Timestamp = relation.Timestamp.ToString("o", CultureInfo.InvariantCulture);
                exportedRelation.User      = relation.User.Name;
                exportedRelation.Uid       = relation.User.Id;
                exportedRelation.Visible   = relation.Visible;
                exportedRelation.Action    = FormatOsmObjectAction(relation.Action);
                exportedRelation.Version   = 1;
                exportedRelation.Changeset = relation.ChangesetId;

                exportedRelation.Member = new List <osmRelationMember> ();
                foreach (OsmRelationMember member in relation.EnumerateMembers())
                {
                    osmRelationMember exportedMember = new osmRelationMember();
                    exportedMember.Type = FormatOsmReferenceType(member.MemberReference.ReferenceType);
                    exportedMember.Ref  = member.MemberReference.ReferenceId;
                    exportedMember.Role = member.Role;
                    exportedRelation.Member.Add(exportedMember);
                }

                exportedRelation.Tag = new List <tag> ();
                foreach (OsmTag tag in relation.EnumerateTags())
                {
                    exportedRelation.Tag.Add(new tag(tag.Key, tag.Value));
                }

                osmData.Relation.Add(exportedRelation);
            }

            return(osmData);
        }
Beispiel #14
0
    public static GISdata LoadOSM(string path)
    {
        GISdata loadedData = new GISdata();
        osm     Osm        = new osm();
        //najpierw ładujemy ten osm który zawiera wszystkie dane
        XmlSerializer serializer = new XmlSerializer(typeof(osm));
        StreamReader  reader     = new StreamReader(path);

        Osm = (osm)serializer.Deserialize(reader);
        reader.Close();

        osmNode[] osmNodes    = Osm.node;
        osmWay[]  osmWays     = Osm.way;
        GISnode   currentNode = null;
        GISway    currentWay  = null;
        double    minLat      = double.MaxValue;
        double    maxLat      = double.MinValue;
        double    minLon      = double.MaxValue;
        double    maxLon      = double.MinValue;

        Dictionary <long, GISnode> nodeDic = new Dictionary <long, GISnode>();

        //wczytujemy najpierw nody bo są potrzebne przy drogach
        foreach (osmNode node in osmNodes)
        {
            double currentLat = double.Parse(node.lat, CultureInfo.InvariantCulture);
            double currentLon = double.Parse(node.lon, CultureInfo.InvariantCulture);
            //aktualny node tworzony - id, współrzędne
            currentNode = new GISnode(Convert.ToInt64(node.id), currentLat, currentLon);
            //sprawdzamy czy ma tagi
            if (node.tag != null)
            {
                foreach (tag nodeTag in node.tag)
                {
                    //dodajemy każdy tag do słownika
                    currentNode.tags.Add(nodeTag.k, nodeTag.v);
                }
            }
            //ustawiamy visibility i dodajemy
            currentNode.visible = Convert.ToBoolean(node.visible);
            loadedData.nodeContainer.Add(currentNode);
            nodeDic.Add(currentNode.id, currentNode);
            if (currentLat > maxLat)
            {
                maxLat = currentLat;
            }
            if (currentLon > maxLon)
            {
                maxLon = currentLon;
            }
            if (currentLat < minLat)
            {
                minLat = currentLat;
            }
            if (currentLon < minLon)
            {
                minLon = currentLon;
            }
        }

        foreach (osmWay way in osmWays)
        {
            //aktualny way tworzony - tylko id
            currentWay = new GISway(Convert.ToInt64(way.id));
            //sprawdzamy czy ma tagi
            if (way.tag != null)
            {
                foreach (tag wayTag in way.tag)
                {
                    //dodajemy tagi
                    currentWay.tags.Add(wayTag.k, wayTag.v);
                }
            }
            //przechodzimy się po wszystkich nodach waywa
            foreach (osmWayND wayNode in way.nd)
            {
                //szukamy w nodach już dodanych tego aktualnego (żeby była referencja) i dodajemy
                //GISnode node = loadedData.nodeContainer.Find(i => i.id == Convert.ToInt64(wayNode.@ref));//nieefektywne gówno
                GISnode node = null;
                nodeDic.TryGetValue(Convert.ToInt64(wayNode.@ref), out node);
                if (node == null)
                {
                    Debug.LogWarning("Duży problem z plikiem OSM");
                }
                currentWay.localNodeContainer.Add(node);
            }
            //ustawiamy visibility i dodajemy
            currentWay.visible = Convert.ToBoolean(way.visible);
            loadedData.wayContainer.Add(currentWay);
        }
        loadedData.maxLat = maxLat;
        loadedData.maxLon = maxLon;
        loadedData.minLat = minLat;
        loadedData.minLon = minLon;
        return(loadedData);
    }
Beispiel #15
0
        public override void Merge(string mergeFile)
        {
            osm osmExistingFile = OsmClient06.LoadFile(mergeFile);

            osmDb.ImportData(osmExistingFile);
        }
        //
        // GET: /OsmImport/
        public ActionResult Parkings(string osmFile, double latMin = 0, double lonMin = 0, double latMax = 0, double lonMax = 0)
        {
            object objOsm = DeserializzaDaFileSystemXmlReader(typeof(osm), Server.MapPath("~/Modules/Laser.Orchard.Maps/Contents/Osm/" + osmFile));

            osm osm = (osm)objOsm;

            int numParking      = 0;
            int newParking      = 0;
            int unnamedParkings = 0;

            //verificare se leggere anche le way
            foreach (node objnode in osm.node)
            {
                try {
                    if (objnode.tag != null)
                    {
                        bool   found        = false;
                        string name         = "ND";
                        int?   capacita     = null;
                        string address      = "";
                        string locationInfo = "";
                        if ((objnode.lat >= latMin && objnode.lat <= latMax && objnode.lon >= lonMin && objnode.lon <= lonMax) || latMin + latMax + lonMin + lonMax == 0)
                        {
                            foreach (tag objtag in objnode.tag)
                            {
                                if (objtag.k.CompareTo("amenity") == 0 && objtag.v.CompareTo("parking") == 0)
                                {
                                    /*
                                     * <tag k='amenity' v='parking' />
                                     * <tag k='name' v='Parcheggio Hotel beau Site' />
                                     * <tag k='parking' v='surface' /><tag k='parking' v='underground' />
                                     * <tag k='capacity' v='15' />
                                     * <tag k='access' v='private' />
                                     *
                                     */
                                    //è un parcheggio, lo inserisco in db (o aggiorno quello esistente)
                                    found = true;
                                    numParking++;
                                }
                                if (objtag.k.CompareTo("name") == 0)
                                {
                                    name = objtag.v;
                                }
                                if (objtag.k.CompareTo("capacity") == 0)
                                {
                                    //trovato caso capacity = no pernotto legato ad un ristorante, valutare se leggere anche valori testuali (non ha senso per parcheggi)
                                    int temp;
                                    if (int.TryParse(objtag.v, out temp))
                                    {
                                        capacita = temp;
                                    }
                                }
                            }

                            if (found)
                            {
                                var resp         = MakeRequest(String.Format("https://maps.googleapis.com/maps/api/geocode/json?latlng={0},{1}", objnode.lat.ToString().Replace(",", "."), objnode.lon.ToString().Replace(",", ".")));
                                var geocodedName = resp.results.FirstOrDefault();
                                if (geocodedName != null)
                                {
                                    if (name == "ND")
                                    {
                                        unnamedParkings++;
                                        name         = geocodedName.formatted_address;
                                        locationInfo = "[null]";
                                    }
                                    address = geocodedName.formatted_address;
                                }
                                if (name == "ND")
                                {
                                    name        += " - " + objnode.id.ToString();
                                    locationInfo = "";
                                }
                                else
                                {
                                    locationInfo = locationInfo == "[null]" ? "" : name;
                                }
                                var parkContentId = 0;
                                parkContentId = _fieldIndexRecord.Fetch(
                                    f => f.DecimalFieldIndexRecords.Any <DecimalFieldIndexRecord>(
                                        r =>
                                        r.PropertyName == "Parcheggio.OsmId." &&
                                        r.Value == objnode.id
                                        )
                                    ).Select(c => c.Id).FirstOrDefault();
                                ContentItem park = null;
                                park = _contentManager.Get(parkContentId);
                                if (park == null)
                                {
                                    newParking++;
                                    park = _contentManager.New("Parcheggio");
                                    _contentManager.Create(park, VersionOptions.Latest);
                                }


                                ((dynamic)park).TitlePart.Title         = name;
                                ((dynamic)park).MapPart.Longitude       = (float)objnode.lon;
                                ((dynamic)park).MapPart.Latitude        = (float)objnode.lat;
                                ((dynamic)park).MapPart.LocationInfo    = locationInfo;
                                ((dynamic)park).MapPart.LocationAddress = address;

                                if (String.IsNullOrWhiteSpace(((dynamic)park).AutoroutePart.DisplayAlias))
                                {
                                    ((dynamic)park).AutoroutePart.DisplayAlias = _autorouteService.Value.GenerateAlias(((dynamic)park).AutoroutePart);
                                    ((dynamic)park).AutoroutePart.DisplayAlias = _autorouteService.Value.PublishAlias(((dynamic)park).AutoroutePart);
                                }

                                ((dynamic)park).Parcheggio.Capacity.Value   = (Decimal)(capacita != null ? capacita : 0);
                                ((dynamic)park).Parcheggio.OsmId.Value      = (Decimal)objnode.id;
                                ((dynamic)park).Parcheggio.OsmVersion.Value = (Decimal)objnode.version;
                                _fieldIndexService.Set(((dynamic)park).FieldIndexPart, "Parcheggio", "Capacity", "", (Decimal)(capacita != null ? capacita : 0), typeof(Decimal));
                                _fieldIndexService.Set(((dynamic)park).FieldIndexPart, "Parcheggio", "OsmId", "", (Decimal)objnode.id, typeof(Decimal));
                                _fieldIndexService.Set(((dynamic)park).FieldIndexPart, "Parcheggio", "OsmVersion", "", (Decimal)objnode.version, typeof(Decimal));
                                _contentManager.Publish(park);
                                //#if DEBUG
                                //                                if (numParking > 9) {
                                //                                    break;
                                //                                }
                                //#endif
                            }
                        }
                    }
                } catch (Exception ex2) {
                    Log.Error(ex2, "Object Node Id: " + objnode.id);

                    // LogErrore
                } finally {
                    osm = null;
                }
            }
            osm = null;
            var model = new ImportResult {
                UnnamedParkings = unnamedParkings, NewParkings = newParking, Parkings = numParking
            };

            return(View(model));
        }