Example #1
0
    public POI ConvertToPOI(decimal locationx, decimal locationy, int radius)
    {
        POI _poi = new POI();

        _poi.layer       = "rhdhvlocations";
        _poi.morePages   = false;
        _poi.nextPageKey = "67234fga";

        foreach (AGSfeature feat in _features)
        {
            try
            {
                Hotspot hotspot = new Hotspot();
                if (feat.attributes["id"] != null)
                {
                    hotspot.id = feat.attributes["id"].ToString();
                }
                else
                {
                    hotspot.id = "1";
                }
                hotspot.lat = (int)(feat.geometry.y * 1000000);
                hotspot.lon = (int)(feat.geometry.x * 1000000);

                if (feat.attributes["titel_en"] != null)
                {
                    hotspot.title       = feat.attributes["titel_en"].ToString();
                    hotspot.attribution = feat.attributes["titel_en"].ToString();
                }
                else
                {
                    hotspot.title       = "unknown";
                    hotspot.attribution = "unknown";
                }

                if (feat.attributes["oms_en"] != null)
                {
                    hotspot.line2 = feat.attributes["oms_en"].ToString();
                }
                if (feat.attributes["soort"] != null)
                {
                    hotspot.line3 = feat.attributes["soort"].ToString();
                }
                if (feat.attributes["url_en"] != null)
                {
                    hotspot.line4 = feat.attributes["url_en"].ToString();
                }
                else
                {
                    if (feat.attributes["url_nl"] != null)
                    {
                        hotspot.line4 = feat.attributes["url_nl"].ToString();
                    }
                }
                if (feat.attributes["figuur"] != null)
                {
                    hotspot.imageURL = feat.attributes["figuur"].ToString();
                }
                hotspot.distance = 0;
                if (locationx != 0 && locationy != 0)
                {
                    hotspot.distance = (decimal)(((Math.Acos(Math.Sin(((double)locationy * Math.PI / 180)) * Math.Sin((feat.geometry.y * Math.PI / 180)) +
                                                             Math.Cos(((double)locationy * Math.PI / 180)) * Math.Cos((feat.geometry.y * Math.PI / 180)) *
                                                             Math.Cos(((double)locationx - feat.geometry.x) * Math.PI / 180))
                                                   ) * 180 / Math.PI) * 60 * 1.1515 * 1.609344 * 1000);
                }
                hotspot.type = 0;

                hotspot.dimension = 1;
                Object3D obj = new Object3D();
                obj.baseURL    = "http://dev.geosolutions.nl/LayarPOI/assets/jason/";
                obj.full       = "full.l3d";
                obj.size       = 10;
                hotspot.Object = null;

                Transform trans = new Transform();
                trans.angle       = 0;
                trans.rel         = true;
                trans.scale       = 1.0m;
                hotspot.transform = null;

                if (radius == 0)
                {
                    _poi.AddHotspot(hotspot);
                }
                else
                {
                    if (hotspot.distance < radius)
                    {
                        _poi.AddHotspot(hotspot);
                    }
                }
            } catch (Exception err) {
                // nothing
            }
        }

        return(_poi);
    }