public override bool CompileTimeValidate(LocationInfo locationInfo)
        {
            lock (this)
            {
                if (locationInfo.PropertyInfo == null)
                {
                    PostSharpDescription.Add<SomeLocationAspect>(
                        "(SomeLocationAspect) If you 'get' or 'set' me, I'll throw an exception. Good you knew, right? Applied on field: " + locationInfo.FieldInfo.AsSignature(), locationInfo.FieldInfo);
                }
                else
                {
                    MethodInfo getMethod = locationInfo.PropertyInfo.GetGetMethod(true);
                    MethodInfo setMethod = locationInfo.PropertyInfo.GetSetMethod(true);

                    PostSharpDescription.Add<SomeLocationAspect>(
                        "(SomeLocationAspect) If you 'get' or 'set' me, I'll throw an exception. Good you knew, right? Applied on property: " + locationInfo.PropertyInfo.AsSignature(), locationInfo.PropertyInfo);

                    if (getMethod != null)
                    {
                        PostSharpDescription.Add<SomeLocationAspect>(
                            "(SomeLocationAspect) If you 'get' me, I'll throw an exception. Good you knew, right? Applied on method '" + getMethod.Name + "'", locationInfo.PropertyInfo, getMethod);
                    }

                    if (setMethod != null)
                    {
                        PostSharpDescription.Add<SomeLocationAspect>(
                           "(SomeLocationAspect) If you 'set' me, I'll throw an exception. Good you knew, right? Applied on method '" + setMethod.Name + "'", locationInfo.PropertyInfo, setMethod);
                    }
                }
                return base.CompileTimeValidate(locationInfo);
            }
        }
        internal void SetFilter(LocationInfo locationInfo, FilterAttribute filter)
        {
            if ( this.frozen )
                throw new InvalidOperationException();

            this.filteredMembers.Add(locationInfo, filter);
        }
        public static string GetName(SessionPolicy policy, LocationInfo locationInfo, string customName)
        {
            switch (policy)
            {
                case SessionPolicy.Custom:
                    if (customName != null)
                    {
                        return customName;
                    }
                    else
                    {
                        return SiAuto.Main.Name;
                    }

                case SessionPolicy.TypeName:
                    return locationInfo.DeclaringType.Name;

                case SessionPolicy.FullyQualifiedTypeName:
                    return locationInfo.DeclaringType.Namespace + "." + locationInfo.DeclaringType.Name;

                case SessionPolicy.Namespace:
                    return locationInfo.DeclaringType.Namespace;
                case SessionPolicy.MemberName:
                    return locationInfo.Name;
            }

            return SiAuto.Main.Name;
        }
Example #4
0
        /// <summary>
        /// A constructor returning a bounds adjustment object for the given array of locationInfo objects
        /// </summary>
        /// <param name="locationInfoArray"></param>
        /// <param name="DesiredWidth">Desired Width of Bounding rectangle</param>
        /// <param name="DesiredHeight">Desired Height of Bounding rectangle</param>
        /// <returns></returns>
        public static BoundsAdjustment CalculateBounds(LocationInfo[] locationInfoArray, double DesiredMaxWidth, double DesiredMaxHeight)
        {
            double XMax = double.MinValue;
            double YMax = double.MinValue;
            double XMin = double.MaxValue;
            double YMin = double.MaxValue;

            foreach(LocationInfo locInfo in locationInfoArray)
            {
                if(locInfo.X > XMax)
                    XMax = locInfo.X;

                if(locInfo.X < XMin)
                    XMin = locInfo.X;

                if(locInfo.Y > YMax)
                    YMax = locInfo.Y;

                if(locInfo.Y < YMin)
                    YMin = locInfo.Y;
            }

            BoundsAdjustment bounds = new BoundsAdjustment(DesiredMaxWidth, DesiredMaxHeight, XMax,XMin, YMax, YMin);

            return bounds;
        }
 // Called when the position timer triggers, and calculates the next position based on current speed and heading,
 // and adds a little randomization to current heading, speed and accuracy.       
 private void timer_Tick(object sender, object e)
 {
     if (oldPosition == null)
     {
         oldPosition = new LocationInfo()
         {
             Location = new MapPoint(StartLongitude, StartLatitude) { SpatialReference = new SpatialReference(4326) },
             Speed = 0,
             Course = 0,
             HorizontalAccuracy = 20,
         };
     }
     var now = DateTime.Now;
     TimeSpan timeParsed = timer.Interval;
     double acceleration = randomizer.NextDouble() * 5 - 2.5;
     double deltaSpeed = acceleration * timeParsed.TotalSeconds;
     double newSpeed = Math.Max(0, deltaSpeed + oldPosition.Speed);
     double deltaCourse = randomizer.NextDouble() * 30 - 15;
     double newCourse = deltaCourse + oldPosition.Course;
     while (newCourse < 0) newCourse += 360;
     while (newCourse >= 360) newCourse -= 360;
     double distanceTravelled = (newSpeed + oldPosition.Speed) * .5 * timeParsed.TotalSeconds;
     double accuracy = Math.Min(500, Math.Max(20, oldPosition.HorizontalAccuracy + (randomizer.NextDouble() * 100 - 50)));
     var pos = GetPointFromHeadingGeodesic(new Point(oldPosition.Location.X, oldPosition.Location.Y), distanceTravelled, newCourse - 180);
     var newPosition = new LocationInfo()
     {
         Location = new MapPoint(pos.X, pos.Y, new SpatialReference(4326)),
         Speed = newSpeed,
         Course = newCourse,
         HorizontalAccuracy = accuracy,
     };
     oldPosition = newPosition;
     if (LocationChanged != null)
         LocationChanged(this, oldPosition);
 }
Example #6
0
 void RetrieveGPSData()
 {
     currentGPSPosition = Input.location.lastData;
     string gpsString = "::" + currentGPSPosition.latitude + "//" + currentGPSPosition.longitude;
     print (gpsString);
     //outputText1.text = gpsString;
 }
        private Func<object, PropertyChangedEventHandler> GetHandlerFirstTime(LocationInfo locationInfo)
        {
            Type fieldType = typeof(PropertyChangedEventHandler);

            var fields = from f in locationInfo.DeclaringType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                         where f.FieldType == fieldType
                         select f;

            FieldInfo propertyChangedField = null;
            try
            {
                propertyChangedField = fields.Single();
            }
            catch (InvalidOperationException)
            {
                throw new Exception(string.Format("The {0} aspect is only compatible with the simple scenario of a single {1} field.", GetType().Name, fieldType.Name));
            }

            // (object x) => (([Type])x).[Field]
            ParameterExpression obj = Expression.Parameter(typeof(object));
            UnaryExpression convertObj = Expression.Convert(obj, locationInfo.DeclaringType);
            MemberExpression getField = Expression.PropertyOrField(convertObj, propertyChangedField.Name);

            Expression<Func<object, PropertyChangedEventHandler>> expression = Expression.Lambda<Func<object, PropertyChangedEventHandler>>(getField, obj);

            return expression.Compile();
        }
Example #8
0
    IEnumerator getLocation()
    {
        // Wait until service initializes
        int maxWait = 20;
        while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
        {
            yield return new WaitForSeconds(1);
            maxWait--;
        }

        // Service didn't initialize in 20 seconds
        if (maxWait < 1)
        {
            Debug.Log("Timed out");
            yield break;
        }

        // Connection has failed
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            print("Unable to determine device location");
            yield break;
        }
        else
        {
            locFound = true;
            // Access granted and location value could be retrieved
            Debug.Log("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
        }
        gpsPos = new LocationInfo();
        // Stop service if there is no need to query location updates continuously
        //Input.location.Stop();
    }
Example #9
0
        public static void OnLogin(LoginEventArgs e)
        {
            Mobile from = e.Mobile;

            if (from == null || from.IsPlayer())
                return;

            if (HasDisconnected(from))
            {
                if (!m_MoveHistory.ContainsKey(from))
                    m_MoveHistory[from] = new LocationInfo(from.Location, from.Map);

                LocationInfo dest = GetRandomDestination();

                from.Location = dest.Location;
                from.Map = dest.Map;
            }
            else if (m_MoveHistory.ContainsKey(from))
            {
                LocationInfo orig = m_MoveHistory[from];
                from.SendMessage("Your character was moved from {0} ({1}) due to a detected client crash.", orig.Location, orig.Map);

                m_MoveHistory.Remove(from);
            }
        }
Example #10
0
    void Update()
    {
        locationInfo = Input.location.lastData;
        string lat = gpsActivityJavaClass.CallStatic<string>("getLat");
        string lng = gpsActivityJavaClass.CallStatic<string>("getLng");

        if (Input.location.status == LocationServiceStatus.Failed)
        {
            GameObject.Find("gps_output2").guiText.text = "Unable to determine device location";
        }

        else
        {
            GameObject.Find("gps_output2").guiText.text = "" + locationInfo.latitude + ", " + locationInfo.longitude;
        }

        if (lat != null && lng != null)
        {
            //speed = float.Parse(speedMessage);
            GameObject.Find("gps_output").guiText.text = lat + ", " + lng;
        }
        else
        {
            GameObject.Find("gps_output").guiText.text = "No Position.";
        }
    }
Example #11
0
    public static LocationInfo GetLocationInfo(string ipParam)
    {
        LocationInfo result = null;
        IPAddress i = Dns.GetHostEntry(ipParam).AddressList[0];
        string ip = i.ToString();

        if (!cachedIps.ContainsKey(ip))
        {
            string r;
            using (WebClient webClient = new WebClient())
            {
                r = webClient.DownloadString(
                    String.Format("http://api.hostip.info/?ip={0}&position=true", ip));
            }

            XDocument xmlResponse = XDocument.Parse(r);

            try
            {
                foreach (XElement element in xmlResponse.Root.Nodes())
                {
                    if (element.Name.LocalName == "featureMember")
                    {
                        //element Hostip is the first element in featureMember
                        XElement hostIpNode = (XElement)element.Nodes().First();

                        result = new LocationInfo();

                        //loop thru the elements in Hostip
                        foreach (XElement node in hostIpNode.Elements())
                        {
                            if (node.Name.LocalName == "name")
                                result.Name = node.Value;

                            if (node.Name.LocalName == "countryName")
                                result.CountryName = node.Value;

                            if (node.Name.LocalName == "countryAbbrev")
                                result.CountryCode = node.Value;
                        }
                    }
                }
            }
            catch (NullReferenceException)
            {
                //Looks like we didn't get what we expected.
            }

            if (result != null)
            {
                cachedIps.Add(ip, result);
            }
        }
        else
        {
            result = cachedIps[ip];
        }
        return result;
    }
Example #12
0
        public AstPythonType(PythonAst ast, IPythonModule declModule, ClassDefinition def, string doc, LocationInfo loc) {
            _members = new Dictionary<string, IMember>();

            Name = def.Name;
            Documentation = doc;
            DeclaringModule = declModule;
            Mro = new IPythonType[0];
            Locations = new[] { loc };
        }
 public override void CompileTimeInitialize(LocationInfo locationInfo, AspectInfo aspectInfo)
 {
     RaisePropertyChanged = locationInfo.DeclaringType.GetMethod(
         "RaisePropertyChanged",
         BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
         null,
         new[] { typeof(string) },
         null);
 }
Example #14
0
        public GoogleDirectionsForm(Utils.BasePlugin.Plugin plugin, Framework.Interfaces.ICore core)
            : this()
        {
            _core = core;
            _plugin = plugin;

            this.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_TITLE);
            this.label1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_START);
            this.label3.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_END);
            this.label2.Text = string.Format(Utils.LanguageSupport.Instance.GetTranslation(STR_STOPS), 8);
            this.checkBox1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_AUTOMATICROUTING);
            this.label4.Text = string.Format(Utils.LanguageSupport.Instance.GetTranslation(STR_AVWAYPOINTS), 200);
            this.button1.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADDTOSTOPS);
            this.button5.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_ADDWAYPOINT);
            this.button6.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_CREATEROUTE);
            this.button7.Text = Utils.LanguageSupport.Instance.GetTranslation(STR_PRINT);

            Assembly assembly = Assembly.GetExecutingAssembly();
            using (StreamReader textStreamReader = new StreamReader(assembly.GetManifestResourceStream("GlobalcachingApplication.Plugins.GDirections.content.html")))
            {
                string doc = textStreamReader.ReadToEnd();
                doc = doc.Replace("//defaultCenter", string.Format("var startCenter = new google.maps.LatLng({0});",_core.CenterLocation.SLatLon));
                doc = doc.Replace("Total Distance", Utils.LanguageSupport.Instance.GetTranslation(STR_TOTALDISTANCE));
                webBrowser1.Navigate("about:blank");
                if (webBrowser1.Document != null)
                {
                    webBrowser1.Document.Write(string.Empty);
                }
                webBrowser1.DocumentText = doc;
            }

            LocationInfo li = new LocationInfo();
            li.Location = new Framework.Data.Location(_core.HomeLocation.Lat, _core.HomeLocation.Lon);
            li.Name = string.Format("{0}", Utils.LanguageSupport.Instance.GetTranslation(STR_HOME));
            listBox2.Items.Add(li);
            comboBox1.Items.Add(li);
            comboBox2.Items.Add(li);

            li = new LocationInfo();
            li.Location = new Framework.Data.Location(_core.CenterLocation.Lat, _core.CenterLocation.Lon);
            li.Name = string.Format("{0}", Utils.LanguageSupport.Instance.GetTranslation(STR_CENTER));
            listBox2.Items.Add(li);
            comboBox1.Items.Add(li);
            comboBox2.Items.Add(li);

            var geocaches = Utils.DataAccess.GetSelectedGeocaches(_core.Geocaches).Take(200);
            foreach (Framework.Data.Geocache gc in geocaches)
            {
                li = new LocationInfo();
                li.Location = new Framework.Data.Location(gc.Lat, gc.Lon);
                li.Name = gc.Name ?? "";

                listBox2.Items.Add(li);
                comboBox1.Items.Add(li);
                comboBox2.Items.Add(li);
            }
        }
Example #15
0
 public override bool CompileTimeValidate(LocationInfo locationInfo)
 {
     if (locationInfo.Name != "Horse")
     {
         Message.Write(locationInfo, SeverityType.Error, "MYERRORCODE01", "Location name must be 'horse'");
         return false;
     }
     return true;
 }
 private static string GetDisplayName(LocationInfo location)
 {
     var displayAttribute = location.PropertyInfo.GetCustomAttributes(typeof(DisplayNameAttribute), false).FirstOrDefault();
     if (displayAttribute != null)
     {
         return ((DisplayNameAttribute)displayAttribute).DisplayName;
     }
     return location.Name;
 }
 /// <summary>
 /// Gets the location information such as:
 /// Yükseklik:  28 m. Boylam:  29° 9' D Enlem:  40° 54' K Gün Batımı:  17:10 Gün Doğumu:  07:21
 /// </summary>
 /// <param name="locationInfoNodes">The html location information nodes.</param>
 private static LocationInfo GetLocationInfo(HtmlNodeCollection locationInfoNodes)
 {
     LocationInfo locationInfo = new LocationInfo();
     locationInfo.Altitude = locationInfoNodes[0].LastChild.InnerText.RemoveNbsp();
     locationInfo.Longitude = locationInfoNodes[1].LastChild.InnerText.RemoveNbsp().ReplaceQuoteAndDegree();
     locationInfo.Latitude = locationInfoNodes[2].LastChild.InnerText.RemoveNbsp().ReplaceQuoteAndDegree();
     locationInfo.Sunset = locationInfoNodes[3].LastChild.InnerText.RemoveNbsp();
     locationInfo.Sunrise = locationInfoNodes[4].LastChild.InnerText.RemoveNbsp();
     return locationInfo;
 }
 public override bool CompileTimeValidate(LocationInfo locationInfo)
 {
     if (!typeof (INotifyPropertyChanged).IsAssignableFrom(locationInfo.DeclaringType))
     {
         Message.Write(locationInfo, SeverityType.Error, "Error1",
                       "The type '{0}' must implement INotifyPropertyChanged in order to decorate property '{1}' with NotifyPropertyChangedAspect.",
                       locationInfo.DeclaringType, locationInfo.PropertyInfo);
         return false;
     }
     return base.CompileTimeValidate(locationInfo);
 }
Example #19
0
    // Use this for initialization
    void Start()
    {
        myLocation = new LocationInfo();
        lat = myLocation.latitude;
        lon = myLocation.longitude;

        url = "http://maps.google.com/maps/api/staticmap?center=" + lat + "," + lon + "&zoom=14&size=800x600&maptype=hybrid&sensor=true";

        StartCoroutine(Myyield(url));
        Debug.Log("lat : " + lat + " lon : " + lon);
    }
Example #20
0
		public LocationFinderItem (CustomerProfile person, LocationInfo address)
		{
			this.Type = LocationFinderItemType.Contact;
			this.DataItem = address;

			//this.Text = string.Format ("{0} {1}", person.FirstName, person.LastName);
			this.Detail = address.StreetAddress;			

			this.FormattedAddress = address.FormattedAddress;
			this.Lat = address.Lat;
			this.Lng = address.Lng;
		}
        public override bool CompileTimeValidate(LocationInfo locationInfo)
        {
            Type requiredType = typeof(INotifyPropertyChanged);

            PropertyInfo property = locationInfo.PropertyInfo;
            if (property == null || !requiredType.IsAssignableFrom(property.DeclaringType))
            {
                throw new Exception(string.Format("The {0} aspect can only be applied to properties of types implementing {1}.", GetType().Name, requiredType.Name));
            }

            return base.CompileTimeValidate(locationInfo);
        }
        public override bool CompileTimeValidate(LocationInfo locationInfo)
        {
            if (!typeof (FrameworkElement).IsAssignableFrom(locationInfo.DeclaringType))
            {
                Message.Write(locationInfo, SeverityType.Error, "Error2",
                              @"The type {0} must derive from FrameworkElement in order to decorate property '{1}' with ResourceBoundPropertyAspect.",
                              locationInfo.DeclaringType, locationInfo.PropertyInfo);

                return false;
            }
            return base.CompileTimeValidate(locationInfo);
        }
		protected override LocationInfo[] ParseLookupResults ()
		{
			List<LocationInfo> addresses = new List<LocationInfo> ();

			LocationInfo info = new LocationInfo () { ProviderType = LocationLookupProviderType.Google };

			AddressLookupGoogle.PopulateInfo (info, this.Results);

			addresses.Add (info);

			return addresses.ToArray ();
		}
 void Update()
 {
     Input.location.Start();
     if(isEnabled)
     {
         if (isReadyToCalibrateLP)
         {
             lastPoint = Input.location.lastData;
             isReadyToCalibrateLP = false;
             StartCoroutine("timer");
         }
      }
 }
Example #25
0
        public override bool CompileTimeValidate(LocationInfo locationInfo)
        {
            if (!locationInfo.LocationType.IsInterface)
            {
                Message.Write(SeverityType.Error, "001", "LoadDependency can only be used on Interfaces in {0}.{1}", locationInfo.DeclaringType, locationInfo.Name);
                return false;
            }

            _type = ObjectFactory.GetInstanceType(locationInfo.LocationType);
            if (_type == null)
            {
                Message.Write(SeverityType.Error, "002", "A concrete type was not found for {0}.{1}", locationInfo.DeclaringType, locationInfo.Name);
                return false;
            }
            return true;
        }
 public override bool CompileTimeValidate(LocationInfo locationInfo)
 {
     if (IsGuid && (locationInfo.LocationType != typeof(String) && locationInfo.LocationType != typeof(Guid)))
     {
         //Message.Write(SeverityType.Warning, "Initialize00", string.Format("[Initialize] on {0}.{1}", locationInfo.DeclaringType.Name, locationInfo.Name));
         //Message.Write(SeverityType.Warning, "Initialize00", string.Format("IsGuid == {0}", IsGuid));
         //Message.Write(SeverityType.Warning, "Initialize00", string.Format("LocationType == {0}", locationInfo.LocationType));
         //Message.Write(SeverityType.Warning, "Initialize00", string.Format("LocationType != typeof(string) == {0}", locationInfo.LocationType != typeof(string)));
         //Message.Write(SeverityType.Warning, "Initialize00", string.Format("LocationType != typeof(Guid) == {0}", locationInfo.LocationType != typeof(Guid)));
         Message.Write(MessageLocation.Of(locationInfo), SeverityType.Error, "Initialize01", "Only string and Guid types can be initialized with IsGuid = true");
     }
     if (IsGuid && _defaultValue != null)
         Message.Write(MessageLocation.Of(locationInfo), SeverityType.Error, "Initialize02", "Cannot specify a default value with IsGuid = true");
     if (locationInfo.LocationType.IsInterface)
         Message.Write(MessageLocation.Of(locationInfo), SeverityType.Error, "Initialize03", string.Format("Cannot initialize a property that is an interface type (in {0}.{1})", locationInfo.DeclaringType.Module, locationInfo.Name));
     return true;
 }
        /// <summary>
        /// Called by the <b>ProvideAspects</b> method of <see cref="FieldValidationAttribute"/>.
        /// Since a type can have many validated fields but needs a single instance of the current type-level aspect,
        /// this method ensures that each validated type has a single <see cref="TypeValidationAspect"/>
        /// and registers all validated fields in this aspect.
        /// </summary>
        /// <param name="field">Validated field.</param>
        /// <param name="validator">Field validator.</param>
        /// <param name="aspects">Collection to which the new aspect should (eventually) be added.</param>
        internal static IEnumerable<AspectInstance> RegisterFieldValidator( LocationInfo location, FieldValidationAttribute validator)
        {
            Type declaringType = location.DeclaringType;
            TypeValidationAspect instance;

            // Do I have already an aspect for this type?
            if ( !instances.TryGetValue( declaringType.FullName, out instance ) )
            {
                // No? Create one.
                instance = new TypeValidationAspect();
                instances.Add( declaringType.FullName, instance );
                yield return new AspectInstance( declaringType, instance );
            }

            // Index the validator in the new aspect instance.
            instance.validators.Add( validator );
        }
 public override bool CompileTimeValidate(LocationInfo locationInfo)
 {
     // Verify that we have a valid regular expression.
     try
     {
         Regex.IsMatch( "", regexStr );
     }
     catch ( Exception e )
     {
         Message.Write(SeverityType.Error, "CM00003", "Error with [RegexValidation] applied on '{0}': invalid regular expression: {1}",
             locationInfo, e.Message);
         return false;
         
     }
     
     return base.CompileTimeValidate(locationInfo);
 }
    void RetrieveGPSData()
    {
        if (state == STATE.ENABLE) {
            state = STATE.WAIT;

            currentGPSPosition = Input.location.lastData;

            lat = currentGPSPosition.latitude;
            lon = currentGPSPosition.longitude;

            if (Input.location.status == LocationServiceStatus.Stopped) {
                // Dummy Data
                lat = 35.710071f;
                lon = 139.810707f;
            }

            Debug.Log("Refresh");
            var url = "http://maps.googleapis.com/maps/api/staticmap";
            var qs = "";
            //if (!autoLocateCenter) {
            //    if (centerLocation.address != "")
            //        qs += "center=" + HTTP.URL.Encode(centerLocation.address);
            //    else {
            qs += "center=" + string.Format("{0},{1}", lat, lon);
            //    }

            qs += "&zoom=" + zoom.ToString();
            //}
            qs += "&size=" + string.Format("{0}x{0}", size);
            qs += "&scale=" + "2";
            qs += "&maptype=" + "roadmap";

            var usingSensor = false;

            #if UNITY_IPHONE
                    usingSensor = Input.location.isEnabledByUser && Input.location.status == LocationServiceStatus.Running;
            #endif

            qs += "&sensor=" + (usingSensor ? "true" : "false");

            Debug.Log("Refreshed");

            StartCoroutine(Download(url + "?" + qs));
        }
    }
    IEnumerator calculate()
    {
        Debug.Log("Opaaaaaaaaaaaa");
        currentPoint = Input.location.lastData;
        double dLat = (currentPoint.latitude - lastPoint.latitude) * Mathf.Deg2Rad;
        var dLon = (currentPoint.longitude - lastPoint.longitude) * Mathf.Deg2Rad;
        var li = Mathf.Deg2Rad * lastPoint.latitude;
        var li2 = currentPoint.latitude * Mathf.Deg2Rad;

        var a = Math.Sin(dLat / 2) * Math.Sin(dLat / 2) +
                Math.Sin(dLon / 2) * Math.Sin(dLon / 2) * Math.Cos(li) * Math.Cos(li2);
        var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
        sum += R * c;
        // 	Debug.Log("lastpoint " + lastPoint.X + " " + lastPoint.Y);
        //  	Debug.Log("currentpoint " + currentPoint.X + " " + currentPoint.Y);s
        isReadyToCalibrateLP = true;
        yield break;
    }
Example #31
0
        internal void RaiseTestEvent()
        {
            try
            {
                String newSystem;

                if (Program.actualCondition.System == "Eravate")
                {
                    newSystem = "Pai Huldr";
                }
                else
                {
                    newSystem = "Eravate";
                }

                Program.actualCondition.System   = newSystem;
                Program.actualCondition.Location = "";

                var LI = new LocationInfoEventArgs()
                {
                    System   = Program.actualCondition.System,
                    Location = Program.actualCondition.Location
                };
                LocationInfo.Raise(this, LI);


                var EA = new LocationChangedEventArgs()
                {
                    System      = Program.actualCondition.System,
                    Location    = Program.actualCondition.Location,
                    OldSystem   = Program.actualCondition.System,
                    OldLocation = Program.actualCondition.Location,
                    Changed     = enLogEvents.Jump | enLogEvents.System
                };
                LocationChanged.Raise(this, EA);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in RaiseEvent", ex);
            }
        }
Example #32
0
        private void EditLabel(LocationInfo location)
        {
            if (location.Symbol != null)
            {
                //Don't allow edit label on symbols
                return;
            }

            if (location.Label != null)
            {
                using (frmEditLabel frm = new frmEditLabel(location.Label)) {
                    frm.ShowDialog();
                }
            }
            else if (location.Address >= 0)
            {
                AddressInfo relAddress = new AddressInfo()
                {
                    Address = location.Address,
                    Type    = _manager.RelativeMemoryType
                };

                AddressInfo absAddress = DebugApi.GetAbsoluteAddress(relAddress);
                if (absAddress.Address >= 0)
                {
                    CodeLabel label = LabelManager.GetLabel((uint)absAddress.Address, absAddress.Type);
                    if (label == null)
                    {
                        label = new CodeLabel()
                        {
                            Address    = (uint)absAddress.Address,
                            MemoryType = absAddress.Type
                        };
                    }

                    using (frmEditLabel frm = new frmEditLabel(label)) {
                        frm.ShowDialog();
                    }
                }
            }
        }
Example #33
0
        private void updateLocationInfo(string key, GeoLocation location)
        {
            LocationInfo oldInfo         = GeoUtils.getMapSafe(key, locationInfos);
            bool         isNew           = (oldInfo == null);
            bool         changedLocation = (oldInfo != null && !oldInfo.location.Equals(location));
            bool         wasInQuery      = (oldInfo != null && oldInfo.inGeoQuery);

            bool isInQuery = this.locationIsInQuery(location);

            if ((isNew || !wasInQuery) && isInQuery)
            {
                foreach (GeoQueryEventListener listener in this.eventListeners)
                {
                    this.geoFire.raiseEvent(() => {
                        listener.onKeyEntered(key, location);
                    });
                }
            }
            else if (!isNew && changedLocation && isInQuery)
            {
                foreach (GeoQueryEventListener listener in this.eventListeners)
                {
                    this.geoFire.raiseEvent(() => {
                        listener.onKeyMoved(key, location);
                    });
                }
            }
            else if (wasInQuery && !isInQuery)
            {
                foreach (GeoQueryEventListener listener in this.eventListeners)
                {
                    this.geoFire.raiseEvent(() => {
                        listener.onKeyExited(key);
                    });
                }
            }
            LocationInfo newInfo = new LocationInfo(location, this.locationIsInQuery(location));

            //this.locationInfos.Add(key, newInfo);
            GeoUtils.setMapSafe(key, newInfo, locationInfos);
        }
Example #34
0
 public decimal Insert(LocationInfo Obj_info)
 {
     try
     {
         OracleParameter paramReturn = new OracleParameter("p_return", OracleDbType.Decimal, ParameterDirection.Output);
         OracleHelper.ExecuteNonQuery(Common.gConnectString, CommandType.StoredProcedure, "pkg_location.Proc_Insert",
                                      new OracleParameter("p_code", OracleDbType.Varchar2, Obj_info.Code, ParameterDirection.Input),
                                      new OracleParameter("p_name", OracleDbType.Varchar2, Obj_info.Name, ParameterDirection.Input),
                                      new OracleParameter("p_level_type", OracleDbType.Decimal, Obj_info.Level_type, ParameterDirection.Input),
                                      new OracleParameter("p_parent_id", OracleDbType.Decimal, Obj_info.Parent_Id, ParameterDirection.Input),
                                      new OracleParameter("p_parent_name", OracleDbType.Varchar2, Obj_info.Parent_Name, ParameterDirection.Input),
                                      new OracleParameter("p_notes", OracleDbType.Varchar2, Obj_info.Notes, ParameterDirection.Input),
                                      paramReturn);
         return(Convert.ToDecimal(paramReturn.Value.ToString()));
     }
     catch (Exception ex)
     {
         NaviCommon.Common.log.Error(ex.ToString());
         return(-1);
     }
 }
Example #35
0
    void Start()
    {
        animator = gameObject.GetComponent <Animator>();

        Input.location.Start(0.5f); // GPS사용 선언
        int wait = 1000;

        if (Input.location.isEnabledByUser)                                                 //GPS 사용가능
        {
            while (Input.location.status == LocationServiceStatus.Initializing && wait > 0) //초기화 진행
            {
                wait--;
            }
            currentGPSPosition = Input.location.lastData;//gps 위치를 받음
        }

        else//GPS가 없는 경우
        {
            Debug.Log("GPS 상태를 확인해주세요");
        }
    }
Example #36
0
        public ParseFileResult Parse(Stream stream, LocationInfo locationInfo)
        {
            DataFile = GetDataFile(stream);

            if (DataFile == null)
            {
                return(ParseFileResult.CannotParse());
            }

            if (locationInfo == null)
            {
                if (string.IsNullOrEmpty(DataFile.Properties.SiteNumber))
                {
                    return(ParseFileResult.SuccessfullyParsedButDataInvalid($"No {nameof(DataFile.Properties.SiteNumber)} property is set, so no AQUARIUS location can be inferred. Try uploading the file directly to a location."));
                }

                locationInfo = _resultsAppender.GetLocationByIdentifier(DataFile.Properties.SiteNumber);
            }

            return(AppendResults(locationInfo));
        }
        public async Task <ActionResult> Create([Bind(Include = "NameOfActivity,LocationOfActivity,Latitude,Longitude,City,State,TimeOfActivity,HowManyMembersInvolved,EstimatedCostOfActivity")] MadeActivites madeActivites)
        {
            if (ModelState.IsValid)
            {
                string     apiCall = "https://maps.googleapis.com/maps/api/geocode/json?address=" + AddPluses(madeActivites.LocationOfActivity) + ",+" + AddPluses(madeActivites.City) + ",+" + AddPluses(madeActivites.State) + "&key=AIzaSyBeWLVk14n3OzLLKLvDvUyWspH929EcEaY";
                HttpClient client  = new HttpClient();
                //make a request for api call set up base address url
                client.BaseAddress = new Uri(apiCall);
                HttpResponseMessage response = await client.GetAsync(apiCall);

                LocationInfo location = JsonConvert.DeserializeObject <LocationInfo>(await response.Content.ReadAsStringAsync());
                madeActivites.Latitude  = location.Results[0].Geometry.Location.Lat.ToString();
                madeActivites.Longitude = location.Results[0].Geometry.Location.Lng.ToString();

                db.MadeActivites.Add(madeActivites);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(madeActivites));
        }
Example #38
0
        public bool TryLookup(double latitude, double longitude, out LocationInfo locationInfo)
        {
            var downloader = new Downloader {
                EnableCompression = true
            };

            downloader.Headers["Accept"] = "application/json";
            // Google enables compressed output only, if a valid User-Agent is sent!
            downloader.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0";
            GoogleResults results = downloader.Download <GoogleResults>(BuildUrl(latitude, longitude));

            if (results == null || results.Results == null || results.Results.Count == 0)
            {
                locationInfo = null;
                return(false);
            }
            locationInfo           = results.Results[0].ToLocation();
            locationInfo.Latitude  = latitude;
            locationInfo.Longitude = longitude;
            return(true);
        }
Example #39
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Finds the next occurence.
        /// </summary>
        /// <param name="startLocation">The selection level information, property tag and
        /// character offset that represent the location where the search should start.</param>
        /// <returns>
        /// A LocationInfo thingy if a match was found, otherwise <c>null</c>.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public LocationInfo FindNext(LocationInfo startLocation)
        {
            m_StartLocation = startLocation;
            m_LocationFound = null;
            m_fHitLimit     = false;

            Reset();             // Just in case
            // Enhance JohnT: if we need to handle more than one root object, this would
            // be one place to loop over them.
            m_vc.Display(this, m_hvoCurr, m_frag);

            if (m_LocationFound == null && m_fHitLimit)
            {
                m_LimitLocation = null;
            }
            else if (m_LimitLocation == null)
            {
                m_LimitLocation = new LocationInfo(startLocation);
            }
            return(m_LocationFound);
        }
Example #40
0
        public ActionResult findDriver(Trip model)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            ListDriverNearLocation = new List <DriverInfomation>();

            //From = getLocationFromAddress(model.tripFrom);
            //To = getLocationFromAddress(model.tripTo);
            LocationInfo from = new LocationInfo(), to = new LocationInfo();

            from.address    = model.tripFrom; to.address = model.tripTo;
            Session["From"] = model.tripFrom;
            Session["To"]   = model.tripTo;
            DirectionInfo direction = getDirection(from, to);


            return(View());
        }
Example #41
0
        public void PARSER_SHOULD_ADD_METHOD_NAME_WHEN_LOCATION_INFO_IS_REQUIRED()
        {
            //Arrange
            var locationInfo = new LocationInfo("class", "method", "file", "line");
            var loggingEvent = new LoggingEvent(new LoggingEventData {
                LocationInfo = locationInfo
            });
            var parser           = new BasicLoggingEventParser(string.Empty, FixFlags.LocationInfo, true, _exceptionFactory);
            var resultDictionary = new Dictionary <string, object>();

            //Act
            parser.ParseLocationInfo(loggingEvent, resultDictionary);

            //Assert
            var resultLocationInfo = resultDictionary["LocationInformation"] as Dictionary <string, object>;

            if (resultLocationInfo != null)
            {
                resultLocationInfo["MethodName"].Should().BeEquivalentTo(locationInfo.MethodName);
            }
        }
Example #42
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="inLocation"></param>
        /// <param name="inCanvas"></param>
        /// <param name="inImgWidth"></param>
        /// <param name="inImgHeight"></param>
        private void calculateLandscapeImgDimensionsInCanvas(LocationInfo inLocation, Control inCanvas, ref double inImgWidth, ref double inImgHeight)
        {
            double locationRatio = resolutionRatio(inLocation);

            if (inCanvas.Width >= inCanvas.Height)
            {
                inImgHeight = inCanvas.Height;
                inImgWidth  = inImgHeight * locationRatio;

                if (inImgWidth > inCanvas.Width)
                {
                    inImgWidth  = inCanvas.Width;
                    inImgHeight = inImgWidth / locationRatio;
                }
            }
            else
            {
                inImgWidth  = inCanvas.Width;
                inImgHeight = inImgWidth / locationRatio;
            }
        }
Example #43
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="locations"></param>
        /// <returns></returns>
        public List <LocationInfo> GetListForInterfaceDataSync(List <string> locations)
        {
            string sql = "select [ID],[LOCATION] "
                         + "from [LES].[TM_BAS_LOCATION] with(nolock) "
                         + "where [VALID_FLAG] = 1 and [LOCATION] in ('" + string.Join("','", locations.ToArray()) + "');";
            Database            db   = DatabaseFactory.CreateDatabase();
            DbCommand           cmd  = db.GetSqlStringCommand(sql);
            List <LocationInfo> list = new List <LocationInfo>();

            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                while (dr.Read())
                {
                    LocationInfo info = new LocationInfo();
                    info.Id       = DBConvert.GetInt64(dr, dr.GetOrdinal("ID"));
                    info.Location = DBConvert.GetString(dr, dr.GetOrdinal("LOCATION"));
                    list.Add(info);
                }
            }
            return(list);
        }
Example #44
0
        private SearchLocation GetSiteVisitLocation(LocationInfo locationInfo)
        {
            var searchResults = _siteVisit.Get(new GetSearchLocations {
                SearchText = locationInfo.Identifier
            });

            if (searchResults.LimitExceeded)
            {
                throw new ExpectedException($"Cannot resolve location ID for identifier='{locationInfo.Identifier}'. LimitExceeded=true. Results.Count={searchResults.Results.Count}");
            }

            var location = searchResults.Results
                           .SingleOrDefault(l => l.Identifier == locationInfo.Identifier && l.Name == locationInfo.LocationName);

            if (location == null)
            {
                throw new ExpectedException($"Cannot resolve locationID for unknown identifier='{locationInfo.Identifier}', even with Results.Count={searchResults.Results.Count}");
            }

            return(location);
        }
Example #45
0
        private int DeleteLocation(LocationInfo locationInfo)
        {
            ++InspectedLocations;

            if (!ConfirmLocationDeletion(locationInfo))
            {
                return(0);
            }

            Log.Info($"Deleting location '{locationInfo.Identifier}' ...");
            var deletedLocation = DeleteLocationByLocationInfo(locationInfo);

            Log.Info($"Deleted location '{locationInfo.Identifier}' successfully.");

            if (Context.RecreateLocations)
            {
                RecreateLocation(deletedLocation);
            }

            return(1);
        }
Example #46
0
        public async Task SetupDataStream(bool remote, string accountName, string accountKey, string homeId, string appId, string streamId)
        {
            StreamFactory sf = StreamFactory.Instance;

            CallerInfo ci     = new CallerInfo(null, appId, appId, 0);
            FqStreamID fq_sid = new FqStreamID(homeId, appId, streamId);

            if (remote)
            {
                LocationInfo li = new LocationInfo(accountName, accountKey, SynchronizerType.Azure);
                datastream = await Task.Run(() => sf.openValueDataStream <StrKey, StrValue>
                                                (fq_sid, ci, li, StreamFactory.StreamSecurityType.Plain, CompressionType.None, StreamFactory.StreamOp.Read,
                                                null, 4 * 1024 * 1024, 1, null, true));
            }
            else
            {
                datastream = await Task.Run(() => sf.openValueDataStream <StrKey, StrValue>
                                                (fq_sid, ci, null, StreamFactory.StreamSecurityType.Plain, CompressionType.None, StreamFactory.StreamOp.Read,
                                                null, 4 * 1024 * 1024, 1, null));
            }
        }
Example #47
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Member AddStringAltMember
        /// </summary>
        /// <param name="tag">tag</param>
        /// <param name="ws">ws</param>
        /// <param name="vwvc">_vwvc</param>
        /// ------------------------------------------------------------------------------------
        public override void AddStringAltMember(int tag, int ws, IVwViewConstructor vwvc)
        {
            CheckDisposed();

            if (Finished)
            {
                return;
            }

            base.AddStringAltMember(tag, ws, vwvc);

            if (m_StartLocation != null && !CurrentLocationIsStartLocation(tag))
            {
                return;
            }

            DoFind(m_sda.get_MultiStringAlt(m_hvoCurr, tag, ws), tag);

            // We now processed the start location, so continue normally
            m_StartLocation = null;
        }
Example #48
0
        private string GetLocationSummary3X(LocationInfo location)
        {
            var timeSeries = Client.Publish
                             .Get(new Publish3x.TimeSeriesDescriptionServiceRequest {
                LocationIdentifier = location.Identifier
            })
                             .TimeSeriesDescriptions;

            var derivedTimeSeriesCount = timeSeries
                                         .Count(ts => !BasicTimeSeriesTypes.Contains(ts.TimeSeriesType));

            var ratingModels = Client.Publish
                               .Get(new Publish3x.RatingModelDescriptionListServiceRequest {
                LocationIdentifier = location.Identifier
            })
                               .RatingModelDescriptions;

            var fieldVisits = Client.Publish
                              .Get(new Publish3x.FieldVisitDescriptionListServiceRequest {
                LocationIdentifier = location.Identifier
            })
                              .FieldVisitDescriptions;

            var locationData = Client.Publish
                               .Get(new Publish3x.LocationDataServiceRequest {
                LocationIdentifier = location.Identifier
            });

            InspectedTimeSeries        += timeSeries.Count;
            InspectedDerivedTimeSeries += derivedTimeSeriesCount;
            InspectedRatingModels      += ratingModels.Count;
            InspectedFieldVisits       += fieldVisits.Count;

            var inventorySummary = FriendlyList(
                TimeSeriesInventory(timeSeries.Count, derivedTimeSeriesCount),
                "rating model".ToQuantity(ratingModels.Count),
                "field visit".ToQuantity(fieldVisits.Count));

            return($"{location.Identifier} - {locationData.LocationName} has {inventorySummary}.");
        }
Example #49
0
    //TODO: update for 1.62
    private void SetMetaData(string mid)
    {
        sPaintStrokes.OnAddToScene();

        bool         useLocation  = Input.location.status == LocationServiceStatus.Running;
        LocationInfo locationInfo = Input.location.lastData;

        // Update for PN 1.62
        LibPlacenote.MapMetadataSettable metadata = new LibPlacenote.MapMetadataSettable();
        metadata.name   = RandomName.Get();
        mLabelText.text = "Saved Map Name: " + metadata.name;
        JObject userdata = new JObject();

        metadata.userdata = userdata;

        //JObject shapeList = Shapes2JSON();
        //userdata["shapeList"] = shapeList;

        userdata[sModels.jsonKey]       = sModels.ToJSON();
        userdata[sPaintStrokes.jsonKey] = sPaintStrokes.ToJSON();
        userdata[sPeople.jsonKey]       = sPeople.ToJSON();


        if (useLocation)
        {
            metadata.location           = new LibPlacenote.MapLocation();
            metadata.location.latitude  = locationInfo.latitude;
            metadata.location.longitude = locationInfo.longitude;
            metadata.location.altitude  = locationInfo.altitude;
        }
        else
        { // default location so that JSON object is not invalid due to missing location data
            metadata.location           = new LibPlacenote.MapLocation();
            metadata.location.latitude  = 50f;
            metadata.location.longitude = 100f;
            metadata.location.altitude  = 10f;
        }

        LibPlacenote.Instance.SetMetadata(mid, metadata);
    }
        private void LoadLocations()
        {
            availableLocations.Clear();

            using (Profile.Settings xmlreader = new Profile.MPSettings())
            {
                for (int i = 0; i < VirtualDirectory.MaxSharesCount; i++)
                {
                    string cityTag         = String.Format("city{0}", i);
                    string strCodeTag      = String.Format("code{0}", i);
                    string strSatUrlTag    = String.Format("sat{0}", i);
                    string strTempUrlTag   = String.Format("temp{0}", i);
                    string strUVUrlTag     = String.Format("uv{0}", i);
                    string strWindsUrlTag  = String.Format("winds{0}", i);
                    string strHumidUrlTag  = String.Format("humid{0}", i);
                    string strPrecipUrlTag = String.Format("precip{0}", i);
                    string city            = xmlreader.GetValueAsString("weather", cityTag, string.Empty);
                    string strCode         = xmlreader.GetValueAsString("weather", strCodeTag, string.Empty);
                    string strSatURL       = xmlreader.GetValueAsString("weather", strSatUrlTag, string.Empty);
                    string strTempURL      = xmlreader.GetValueAsString("weather", strTempUrlTag, string.Empty);
                    string strUVURL        = xmlreader.GetValueAsString("weather", strUVUrlTag, string.Empty);
                    string strWindsURL     = xmlreader.GetValueAsString("weather", strWindsUrlTag, string.Empty);
                    string strHumidURL     = xmlreader.GetValueAsString("weather", strHumidUrlTag, string.Empty);
                    string strPrecipURL    = xmlreader.GetValueAsString("weather", strPrecipUrlTag, string.Empty);
                    if (city.Length > 0 && strCode.Length > 0)
                    {
                        LocationInfo loc = new LocationInfo();
                        loc.City           = city;
                        loc.CityCode       = strCode;
                        loc.UrlSattelite   = strSatURL;
                        loc.UrlTemperature = strTempURL;
                        loc.UrlUvIndex     = strUVURL;
                        loc.UrlWinds       = strWindsURL;
                        loc.UrlHumidity    = strHumidURL;
                        loc.UrlPrecip      = strPrecipURL;
                        availableLocations.Add(loc);
                    }
                }
            }
        }
Example #51
0
        public IEnumerable <AspectInstance> ProvideAspects(object targetElement)
        {
            var parameter = targetElement as ParameterInfo;

            if (parameter != null)
            {
                var method = (MethodBase)parameter.Member;
                var filterMethodArgumentsAspect = GetAspect <FilterMethodArgumentsAspect>(method);
                if (filterMethodArgumentsAspect == null)
                {
                    filterMethodArgumentsAspect = new FilterMethodArgumentsAspect(method);
                    yield return(new AspectInstance(method, filterMethodArgumentsAspect));
                }
                filterMethodArgumentsAspect.SetFilter(parameter, this);
            }
            else
            {
                var locationInfo = LocationInfo.ToLocationInfo(targetElement);
                if (locationInfo.IsStatic)
                {
                    Message.Write(locationInfo, SeverityType.Error, "MY02", "Cannot apply [{0}] to {1} because it is static.",
                                  GetType().Name, locationInfo);
                    yield break;
                }
                var type = locationInfo.DeclaringType;
                if (type.IsValueType)
                {
                    Message.Write(locationInfo, SeverityType.Error, "MY03",
                                  "Cannot apply [{0}] to {1} because the declaring type is a struct.", GetType().Name, locationInfo);
                    yield break;
                }
                var filterTypePropertiesAspect = GetAspect <FilterTypePropertiesAspect>(type);
                if (filterTypePropertiesAspect == null)
                {
                    filterTypePropertiesAspect = new FilterTypePropertiesAspect();
                    yield return(new AspectInstance(type, filterTypePropertiesAspect));
                }
                filterTypePropertiesAspect.SetFilter(locationInfo, this);
            }
        }
Example #52
0
            public void ReadField(VersionedVariable reference, IFieldDefinition field)
            {
                int refId = GetIdFromInterpretation(this.GetInterpretation(reference));

                if (this.currentHeap.TryGetValue(refId, out var locationInfo))
                {
                    if (locationInfo.ContainsField(field))
                    {
                        // It was read successfully
                        return;
                    }
                    else if (refId > VariableState.NullValue)
                    {
                        // Note: This can't happen in higher level languages, because they always
                        //       initialize the fields (e.g. to zero)
                        throw new NotSupportedException(
                                  "Unable to model reading data of explicitly allocated but uninitialized objects");
                    }
                }

                // Fall back to input heap if not found in the current heap
                if (!this.inputHeap.TryGetValue(refId, out locationInfo))
                {
                    locationInfo = new LocationInfo()
                    {
                        LastModifiedVersion = 0
                    };
                    this.inputHeap.Add(refId, locationInfo);
                }

                if (!locationInfo.ContainsField(field))
                {
                    // Read the value from the particular input heap array
                    var fieldArray = this.state.GetFieldArray(field);
                    var valueIntr  = this.smtModel.GetInterpretation(fieldArray.Select(refId));

                    // Store either the reference ID or the value interpretation to the field
                    locationInfo.SetField(field, valueIntr);
                }
            }
        //-----------------------------InitPanel-------------------------------


        public void OnSearchMapsClick()
        {
            MessageManager.Instance.ShowMessage("Searching for saved maps");

            //TODO: later we can use this location info for querying the related maps.
            LocationInfo locationInfo = Input.location.lastData;

            //LibPlacenote.Instance.SearchMaps(locationInfo.latitude, locationInfo.longitude, radiusSearch, (mapList) =>
            LibPlacenote.Instance.SearchMaps(Const.MAP_PREFIX, (mapList) =>
            {
                foreach (Transform t in SelectMapFacade.Instance.mapListContentParent.transform)
                {
                    Destroy(t.gameObject);
                }

                MessageManager.Instance.DebugMessage(string.Format("Found {0} maps.", mapList.Length));
                if (mapList.Length == 0)
                {
                    MessageManager.Instance.ShowMessage("No maps found. Create a map first!");
                    return;
                }

                // Render the map list!
                foreach (LibPlacenote.MapInfo mapId in mapList)
                {
                    if (mapId.metadata.userdata != null)
                    {
                        Debug.Log(mapId.metadata.userdata.ToString(Formatting.None));
                    }

                    AddMapToList(mapId);
                }

                MessageManager.Instance.ShowMessage("Please select a map to load");

                //update UI mode
                UIManager.Instance.SetUIMode(UIManager.UIMode.SelectMap);
                SelectMapFacade.Instance.SetUIMode(SelectMapFacade.UIMode.SelectMap_NoMapSelected);
            });
        }
Example #54
0
        private Location DeleteLocation3X(LocationInfo locationInfo)
        {
            if (Context.RecreateLocations)
            {
                throw new ExpectedException($"Locations cannot be auto re-created on AQTS {Client.ServerVersion}. Stopping before deleting anything.");
            }

            var location = GetSiteVisitLocation(locationInfo);

            using (var soapClient = LegacyServiceClient.Create(Context.Server, Context.Username, Context.Password))
            {
                var locationsDeleted = soapClient.DeleteLocationAndAllContentById(location.Id, preventContentDeletion: false);

                if (locationsDeleted != 1)
                {
                    throw new ExpectedException($"Unable to delete location '{locationInfo.Identifier}'");
                }
            }

            // We can't recreate a location in 3.X, so no need to return a provisioning object
            return(null);
        }
    public void PickLatLong()
    {
        bool         useLocation  = Input.location.status == LocationServiceStatus.Running;
        LocationInfo locationInfo = Input.location.lastData;


        string lats  = locationInfo.latitude.ToString();
        string longs = locationInfo.longitude.ToString();
        string alti  = locationInfo.altitude.ToString();

        Locinfos.text = lats + " - " + longs + " - " + alti;
        Debug.Log("Loc Info" + lats + " - " + longs + " - " + alti);


        //if (useLocation)
        //{
        //    metadata.location = new LibPlacenote.MapLocation();
        //    metadata.location.latitude = locationInfo.latitude;
        //    metadata.location.longitude = locationInfo.longitude;
        //    metadata.location.altitude = locationInfo.altitude;
        //}
    }
Example #56
0
        private void mnuAddToWatch_Click(object sender, EventArgs e)
        {
            LocationInfo location = GetActionTarget();

            if (location.Symbol != null)
            {
                WatchManager.GetWatchManager(_manager.CpuType).AddWatch("[" + location.Symbol.Name + "]");
            }
            else if (location.Label != null)
            {
                string label = location.Label.Label;
                if (location.ArrayIndex.HasValue)
                {
                    label += "+" + location.ArrayIndex.Value.ToString();
                }
                WatchManager.GetWatchManager(_manager.CpuType).AddWatch("[" + label + "]");
            }
            else if (location.Address >= 0)
            {
                WatchManager.GetWatchManager(_manager.CpuType).AddWatch("[$" + location.Address.ToString("X" + _manager.AddressSize.ToString()) + "]");
            }
        }
Example #57
0
        private void generateLocations(ConfigInfo config)
        {
            this.Locations = new List <LocationInfo>();
            int count  = 1;
            int width  = this.Config.Width;
            int height = this.Config.Height;
            int large  = Convert.ToInt32(((width + height) / 2) * 0.1);
            int small  = Convert.ToInt32(((width + height) / 2) * -0.1);

            for (int y = 1; y <= config.Y; y++)
            {
                for (int x = 1; x <= config.X; x++)
                {
                    LocationInfo location = new LocationInfo(count, x, y);
                    location.PlayerId = config.EmptyId;
                    this.setRandomLocation(location);

                    int locationHeigth = height;
                    int locationWidth  = width;
                    if (location.Size == SizeTypes.Large)
                    {
                        locationHeigth += large;
                        locationWidth  += large;
                    }
                    else if (location.Size == SizeTypes.Small)
                    {
                        locationHeigth += small;
                        locationWidth  += small;
                    }

                    this.Config.SetCycle(location);
                    this.Config.SetArmy(location);
                    location.Army = RND.Next(1, location.Army * 2);
                    location.SetSize(locationHeigth, locationWidth);
                    this.Locations.Add(location);
                    count++;
                }
            }
        }
        // GET api/<controller>/5
        public IHttpActionResult Get(int id)
        {
            EarthSkyTimeEntities1 estEnt = new EarthSkyTimeEntities1();

            LocationInfo oLocInfo = new LocationInfo();

            var oLocs = (from l in estEnt.Locations
                         where l.LocationID == id
                         select new { l.LocationName, l.Street1, l.Street2, l.City, l.State, l.Zip }).FirstOrDefault();

            if (oLocs != null)
            {
                oLocInfo.City         = oLocs.City;
                oLocInfo.LocationName = oLocs.LocationName;
                oLocInfo.State        = oLocs.State;
                oLocInfo.Street1      = oLocs.Street1;
                oLocInfo.Street2      = oLocs.Street2;
                oLocInfo.Zip          = oLocs.Zip;
            }

            return(Ok(oLocInfo));
        }
            /// <summary>
            /// Convert the pattern to the rendered message
            /// </summary>
            /// <param name="loggingEvent">the event being logged</param>
            /// <returns>the relevant location information</returns>
            override protected string Convert(LoggingEvent loggingEvent)
            {
                LocationInfo locationInfo = loggingEvent.LocationInformation;

                switch (m_type)
                {
                case FULL_LOCATION_CONVERTER:
                    return(locationInfo.FullInfo);

                case METHOD_LOCATION_CONVERTER:
                    return(locationInfo.MethodName);

                case LINE_LOCATION_CONVERTER:
                    return(locationInfo.LineNumber);

                case FILE_LOCATION_CONVERTER:
                    return(locationInfo.FileName);

                default:
                    return(null);
                }
            }
    private void UpdateSpeed()
    {
        LocationInfo lastData = Input.location.lastData;

        if (lastLocationInfoTimestamp == lastData.timestamp)
        {
            return;
        }

        lastLocationInfoTimestamp = lastData.timestamp;

        if (lastPositions == null)
        {
            lastPositions = new List <LastPositionItem>();
        }

        lastPositions.Add(new LastPositionItem(lastData.longitude, lastData.latitude, lastData.timestamp));
        while (lastPositions.Count > maxPositionCount)
        {
            lastPositions.RemoveAt(0);
        }

        if (lastPositions.Count < 2)
        {
            _speed = 0;
            return;
        }

        LastPositionItem p1 = lastPositions[0];
        LastPositionItem p2 = lastPositions[lastPositions.Count - 1];

        double dx, dy;

        OnlineMapsUtils.DistanceBetweenPoints(p1.lng, p1.lat, p2.lng, p2.lat, out dx, out dy);
        double distance = Math.Sqrt(dx * dx + dy * dy);
        double time     = (p2.timestamp - p1.timestamp) / 3600;

        _speed = Mathf.Abs((float)(distance / time));
    }