コード例 #1
0
 private void OnStateChanged(GpsStatus status)
 {
     this.StateChangedEventHandler?.Invoke(this, new StateChangedEventArgs()
     {
         State = status
     });
 }
コード例 #2
0
ファイル: Gps.cs プロジェクト: Yipps/StonyCampusAR
    private IEnumerator StartLocationService(float desiredAccuracyInMeters, float updateDistanceInMeters)
    {
        // Wait until the editor and unity remote are connected before starting a location service
        if (isUnityRemote)
        {
            yield return(new WaitForSeconds(5));
        }

        // First, check if user has location service enabled
        if (!Input.location.isEnabledByUser)
        {
            Debug.Log("No locations enabled in the device");
            gpsStatus = GpsStatus.Disabled;
            yield break;
        }

        // Start service before querying location
        Input.location.Start(desiredAccuracyInMeters, updateDistanceInMeters);
        gpsStatus = GpsStatus.Started;

        if (isUnityRemote)
        {
            yield return(new WaitForSeconds(5));
        }

        // Wait until service initializes
        int maxWait = 20;

        gpsStatus = GpsStatus.Pending;
        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("Service didn't initialize in 20 seconds");
            gpsStatus = GpsStatus.Failed;
            yield break;
        }

        // Connection has failed
        if (Input.location.status == LocationServiceStatus.Failed)
        {
            gpsStatus = GpsStatus.Failed;
            Debug.Log("Unable to determine device location");
            yield break;
        }
        // Access granted and location value could be retrieved
        else
        {
            gpsStatus = GpsStatus.Succeed;
            latitude  = Input.location.lastData.latitude;
            longitude = Input.location.lastData.longitude;
        }
    }
コード例 #3
0
 private OnUpdate(GpsStatus status)
 {
     if (SynchronizingObject != null && SynchronizingObject.IsInvokeRequired)
     {
         SynchronizingObject.Invoke(() => { OnUpdate(status); }, null);
     }
     else
     {
         if (Update != null)
         {
             Update(this, status);
         }
     }
 }
コード例 #4
0
        public void OnGpsStatusChanged(GpsEvent e)
        {
            GpsStatus gpsStatus = locationManager.GetGpsStatus(null);

            if (gpsStatus != null)
            {
                IIterable satellites  = gpsStatus.Satellites;
                IIterator sat         = satellites.Iterator();
                string    lSatellites = null;
                int       i           = 0;
                while (sat.HasNext)
                {
                    GpsSatellite satellite = sat.Next().JavaCast <GpsSatellite>();
                    Debug.WriteLine(satellite.Prn);
                }
            }
        }
コード例 #5
0
        public void DeInit() // IDeviceGps
        {
            if (locationManager != null)
            {
                locationManager.RemoveUpdates(this);
                locationManager.RemoveGpsStatusListener(this);
                locationManager = null;
            }

            if (location != null)
            {
                location.Reset();
                location = null;
            }

            listener  = null;
            gpsStatus = null;
            status    = IDeviceGpsStatus.ShutOff;
        }
コード例 #6
0
ファイル: RouteInfo.cs プロジェクト: szelusbk/TrackingWebApi
        public override int GetHashCode()
        {
            unchecked
            {
                const int HashingBase       = (int)2166136261;
                const int HashingMultiplier = 16777619;

                int hash = HashingBase;
                hash = (hash * HashingMultiplier) ^ GpsName.GetHashCode();
                hash = (hash * HashingMultiplier) ^ GpsStatus.GetHashCode();
                hash = (hash * HashingMultiplier) ^ Imei.GetHashCode();
                hash = (hash * HashingMultiplier) ^ LastDate.GetHashCode();
                hash = (hash * HashingMultiplier) ^ Battery.GetHashCode();
                hash = (hash * HashingMultiplier) ^ ElapsedTime.GetHashCode();
                hash = (hash * HashingMultiplier) ^ Distance.GetHashCode();
                hash = (hash * HashingMultiplier) ^ Imei.GetHashCode();
                hash = (hash * HashingMultiplier) ^ GoogleDistance.GetHashCode();
                hash = (hash * HashingMultiplier) ^ LastLatitude.GetHashCode();
                hash = (hash * HashingMultiplier) ^ LastLongitude.GetHashCode();
                hash = (hash * HashingMultiplier) ^ ((LatLngList != null) ? LatLngList.GetHashCode() : 0);
                return(hash);
            }
        }
コード例 #7
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.MyButton);

            locationManager = (LocationManager)GetSystemService(Context.LocationService);
            locationManager.AddGpsStatusListener(this);
            locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 0, 0, this);

            GpsStatus gpsStatus = locationManager.GetGpsStatus(null);

            if (gpsStatus != null)
            {
                IIterable satellites  = gpsStatus.Satellites;
                IIterator sat         = satellites.Iterator();
                string    lSatellites = null;
                int       i           = 0;
                while (sat.HasNext)
                {
                    GpsSatellite satellite = sat.Next().JavaCast <GpsSatellite>();
                    Debug.WriteLine(satellite.Prn);
                }
            }


            button.Click += delegate
            {
                button.Text = string.Format("{0} clicks!", count++);
            };
        }
コード例 #8
0
 public GpsStatusEventArgs(GpsStatus status)
 {
     Status = status;
 }
コード例 #9
0
        private async void TimerTick(object sender, EventArgs e)
        {
            var dataService = new DataService();
            //update driver position
            GpsStatus gpsStatus = CrossGeolocator.Current.IsGeolocationEnabled ? GpsStatus.NoError : GpsStatus.GpsTurnOff;

            if (gpsStatus == GpsStatus.GpsTurnOff && !_showError)
            {
                ShowLocationError();
                _showError    = true;
                _listnerStart = false;
            }
            if (!_listnerStart && CrossGeolocator.Current.IsGeolocationEnabled)
            {
                StartListner();
            }
            if (Driver.Current != null)
            {
                Driver.Current.GpsStatus = gpsStatus;
            }
            var result = await dataService.UpdatePositionDriver(_currentPosition, gpsStatus);

            //check new orders
            var orders = await dataService.GetOrdersForDriver();

            if (orders != null && orders.Count > 0)
            {
                var newOrder = orders.Where(x => x.OrderStatus == OrderStatus.NewOrder).FirstOrDefault();
                if (newOrder != null)
                {
                    var status = DataBaseService.SqlLiteDataBaseService.GetLocalOrderStatus(newOrder.OrderId);
                    if (status == null && _newOrders != null && _newOrders.FirstOrDefault(x => x.OrderId == newOrder.OrderId) == null)
                    {
                        var soundPlayer = DependencyService.Get <ISoundPlay>();
                        if (soundPlayer != null)
                        {
                            soundPlayer.PlaySound();
                        }
                        _newOrders.Add(newOrder);
                        if (newOrder.AutoAccept != 1)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                var newPage = new OrderAcceptPage(newOrder);
                                Navigation.PushModalAsync(newPage);
                            });
                        }
                        else
                        {
                            var r = await new DataService().SetOrderStatus(newOrder.OrderId, OrderStatus.DriverAccepted);
                            if (r != null)
                            {
                                DataBaseService.SqlLiteDataBaseService.SaveOrderStatus(newOrder.OrderId, OrderStatus.NewOrder);
                                newOrder.OrderStatus = OrderStatus.NewOrder;
                            }
                        }
                    }
                }
            }
            _orderListPage.UpdataOrders(orders);
        }
コード例 #10
0
 private static void Action(object o, GpsStatus gpsStatus)
 {
     Console.WriteLine(gpsStatus);
 }
コード例 #11
0
        public void OnGpsStatusChanged(GpsEvent e) // GpsStatus.IListener
        {
            if (locationManager != null)
            {
                gpsStatus = locationManager.GetGpsStatus(gpsStatus);

                switch (e)
                {
                case GpsEvent.FirstFix:
                    status = IDeviceGpsStatus.FirstFix;
                    DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString());
                    break;

                case GpsEvent.SatelliteStatus:
                    if (gpsStatus != null)
                    {
                        gpsSatellitesVisible       = 0;
                        gpsSatellitesUsedInFix     = 0;
                        gpsSatellitesWithEphemeris = 0;
                        gpsSatellitesWithAlmanac   = 0;

                        var satellites = gpsStatus.Satellites;
                        if (satellites != null)
                        {
                            Java.Util.IIterator iterator = satellites.Iterator();
                            {
                                while (iterator.HasNext)
                                {
                                    gpsSatellitesVisible++;

                                    var s = (GpsSatellite)iterator.Next();
                                    if (s.UsedInFix())
                                    {
                                        gpsSatellitesUsedInFix++;
                                    }
                                    if (s.HasEphemeris)
                                    {
                                        gpsSatellitesWithEphemeris++;
                                    }
                                    if (s.HasAlmanac)
                                    {
                                        gpsSatellitesWithAlmanac++;
                                    }
                                }
                            }

                            if (gpsSatellitesUsedInFix > 3)
                            {
                                status = IDeviceGpsStatus.Connected;
                            }
                        }
                    }
                    break;

                case GpsEvent.Started:
                    status = IDeviceGpsStatus.Started;
                    DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString());
                    break;

                case GpsEvent.Stopped:
                    status = IDeviceGpsStatus.Stopped;
                    DeviceDebugAndroid.LogToFileMethodStatic("gps: " + status.ToString());
                    break;
                }

                if (listener != null)
                {
                    listener.OnGpsStatusUpdate();
                }
            }
        }
コード例 #12
0
 /// <summary>
 /// Traces the position data.
 /// </summary>
 /// <remarks>Writes the output in GPX format.</remarks>
 public void Trace(GeoData raw, GeoData corrected, GpsStatus gpsStatus, DateTime computerDateTime)
 {
     Trace(raw, corrected, gpsStatus, computerDateTime, null);
 }
コード例 #13
0
        Tag CreateSpecificTag(TagInfo info, string numberValue)
        {
            try
            {
                if (info.IsGps)
                {
                    switch (info.Name.ToLower())
                    {
                    case "gpslatituderef":
                        return(new Tag <GpsLatitudeRef> {
                            TypedValue = GpsLatitudeRef.FromKey(numberValue)
                        });

                    case "gpslongituderef":
                        return(new Tag <GpsLongitudeRef> {
                            TypedValue = GpsLongitudeRef.FromKey(numberValue)
                        });

                    case "gpsaltituderef":
                        return(new Tag <GpsAltitudeRef> {
                            TypedValue = GpsAltitudeRef.FromKey(byte.Parse(numberValue))
                        });

                    case "gpsstatus":
                        return(new Tag <GpsStatus> {
                            TypedValue = GpsStatus.FromKey(numberValue)
                        });

                    case "gpsmeasuremode":
                        return(new Tag <GpsMeasureMode> {
                            TypedValue = GpsMeasureMode.FromKey(numberValue)
                        });

                    case "gpsspeedref":
                        return(new Tag <GpsSpeedRef> {
                            TypedValue = GpsSpeedRef.FromKey(numberValue)
                        });

                    case "gpstrackref":
                        return(new Tag <GpsTrackRef> {
                            TypedValue = GpsTrackRef.FromKey(numberValue)
                        });

                    case "gpsimgdirectionref":
                        return(new Tag <GpsImgDirectionRef> {
                            TypedValue = GpsImgDirectionRef.FromKey(numberValue)
                        });

                    case "gpsdestlatituderef":
                        return(new Tag <GpsDestLatitudeRef> {
                            TypedValue = GpsDestLatitudeRef.FromKey(numberValue)
                        });

                    case "gpsdestlongituderef":
                        return(new Tag <GpsDestLongitudeRef> {
                            TypedValue = GpsDestLongitudeRef.FromKey(numberValue)
                        });

                    case "gpsdestbearingref":
                        return(new Tag <GpsDestBearingRef> {
                            TypedValue = GpsDestBearingRef.FromKey(numberValue)
                        });

                    case "gpsdestdistanceref":
                        return(new Tag <GpsDestDistanceRef> {
                            TypedValue = GpsDestDistanceRef.FromKey(numberValue)
                        });

                    case "gpsdifferential":
                        return(new Tag <GpsDifferential> {
                            TypedValue = GpsDifferential.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                if (info.IsNikon)
                {
                    switch (info.Name.ToLower())
                    {
                    case "colorspace":
                        return(new Tag <NikonColorSpace> {
                            TypedValue = NikonColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "vibrationreduction":
                        return(new Tag <NikonVibrationReduction> {
                            TypedValue = NikonVibrationReduction.FromKey(byte.Parse(numberValue))
                        });

                    case "vrmode":
                        return(new Tag <NikonVRMode> {
                            TypedValue = NikonVRMode.FromKey(byte.Parse(numberValue))
                        });

                    case "imageauthentication":
                        return(new Tag <NikonImageAuthentication> {
                            TypedValue = NikonImageAuthentication.FromKey(byte.Parse(numberValue))
                        });

                    case "actived-lighting":
                        return(new Tag <NikonActiveDLighting> {
                            TypedValue = NikonActiveDLighting.FromKey(ushort.Parse(numberValue))
                        });

                    case "picturecontroladjust":
                        return(new Tag <NikonPictureControlAdjust> {
                            TypedValue = NikonPictureControlAdjust.FromKey(byte.Parse(numberValue))
                        });

                    case "filtereffect":
                        return(new Tag <NikonFilterEffect> {
                            TypedValue = NikonFilterEffect.FromKey(byte.Parse(numberValue))
                        });

                    case "toningeffect":
                        return(new Tag <NikonToningEffect> {
                            TypedValue = NikonToningEffect.FromKey(byte.Parse(numberValue))
                        });

                    case "daylightsavings":
                        return(new Tag <NikonDaylightSavings> {
                            TypedValue = NikonDaylightSavings.FromKey(byte.Parse(numberValue))
                        });

                    case "datedisplayformat":
                        return(new Tag <NikonDateDisplayFormat> {
                            TypedValue = NikonDateDisplayFormat.FromKey(byte.Parse(numberValue))
                        });

                    case "isoexpansion":
                        return(new Tag <NikonIsoExpansion> {
                            TypedValue = NikonIsoExpansion.FromKey(ushort.Parse(numberValue))
                        });

                    case "isoexpansion2":
                        return(new Tag <NikonIsoExpansion2> {
                            TypedValue = NikonIsoExpansion2.FromKey(ushort.Parse(numberValue))
                        });

                    case "vignettecontrol":
                        return(new Tag <NikonVignetteControl> {
                            TypedValue = NikonVignetteControl.FromKey(ushort.Parse(numberValue))
                        });

                    case "autodistortioncontrol":
                        return(new Tag <NikonAutoDistortionControl> {
                            TypedValue = NikonAutoDistortionControl.FromKey(byte.Parse(numberValue))
                        });

                    case "hdr":
                        return(new Tag <NikonHdr> {
                            TypedValue = NikonHdr.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrlevel":
                        return(new Tag <NikonHdrLevel> {
                            TypedValue = NikonHdrLevel.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrsmoothing":
                        return(new Tag <NikonHdrSmoothing> {
                            TypedValue = NikonHdrSmoothing.FromKey(byte.Parse(numberValue))
                        });

                    case "hdrlevel2":
                        return(new Tag <NikonHdrLevel2> {
                            TypedValue = NikonHdrLevel2.FromKey(byte.Parse(numberValue))
                        });

                    case "textencoding":
                        return(new Tag <NikonTextEncoding> {
                            TypedValue = NikonTextEncoding.FromKey(byte.Parse(numberValue))
                        });

                    case "flashmode":
                        return(new Tag <NikonFlashMode> {
                            TypedValue = NikonFlashMode.FromKey(byte.Parse(numberValue))
                        });

                    case "afareamode":
                        return(new Tag <NikonAfAreaMode> {
                            TypedValue = NikonAfAreaMode.FromKey(byte.Parse(numberValue))
                        });

                    case "afpoint":
                        return(new Tag <NikonAfPoint> {
                            TypedValue = NikonAfPoint.FromKey(byte.Parse(numberValue))
                        });

                    case "afpointsinfocus":
                        return(new Tag <NikonAfPointsInFocus> {
                            TypedValue = NikonAfPointsInFocus.FromKey(ushort.Parse(numberValue))
                        });

                    case "nefcompression":
                        return(new Tag <NikonNefCompression> {
                            TypedValue = NikonNefCompression.FromKey(ushort.Parse(numberValue))
                        });

                    case "retouchhistory":
                        return(new Tag <NikonRetouchHistory> {
                            TypedValue = NikonRetouchHistory.FromKey(ushort.Parse(numberValue))
                        });

                    case "flashsource":
                        return(new Tag <NikonFlashSource> {
                            TypedValue = NikonFlashSource.FromKey(byte.Parse(numberValue))
                        });

                    case "flashcolorfilter":
                        return(new Tag <NikonFlashColorFilter> {
                            TypedValue = NikonFlashColorFilter.FromKey(byte.Parse(numberValue))
                        });

                    case "highisonoisereduction":
                        return(new Tag <NikonHighIsoNoiseReduction> {
                            TypedValue = NikonHighIsoNoiseReduction.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                if (info.IsExif)
                {
                    switch (info.Name.ToLower())
                    {
                    case "interopindex":
                        return(new Tag <InteropIndex> {
                            TypedValue = InteropIndex.FromKey(numberValue)
                        });

                    case "subfiletype":
                        return(new Tag <SubfileType> {
                            TypedValue = SubfileType.FromKey(uint.Parse(numberValue))
                        });

                    case "oldsubfiletype":
                        return(new Tag <OldSubfileType> {
                            TypedValue = OldSubfileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "compression":
                        return(new Tag <Compression> {
                            TypedValue = Compression.FromKey(ushort.Parse(numberValue))
                        });

                    case "photometricinterpretation":
                        return(new Tag <PhotometricInterpretation> {
                            TypedValue = PhotometricInterpretation.FromKey(ushort.Parse(numberValue))
                        });

                    case "thresholding":
                        return(new Tag <Thresholding> {
                            TypedValue = Thresholding.FromKey(ushort.Parse(numberValue))
                        });

                    case "fillorder":
                        return(new Tag <FillOrder> {
                            TypedValue = FillOrder.FromKey(ushort.Parse(numberValue))
                        });

                    case "orientation":
                        return(new Tag <Orientation> {
                            TypedValue = Orientation.FromKey(ushort.Parse(numberValue))
                        });

                    case "planarconfiguration":
                        return(new Tag <PlanarConfiguration> {
                            TypedValue = PlanarConfiguration.FromKey(ushort.Parse(numberValue))
                        });

                    case "grayresponseunit":
                        return(new Tag <GrayResponseUnit> {
                            TypedValue = GrayResponseUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "resolutionunit":
                        return(new Tag <ResolutionUnit> {
                            TypedValue = ResolutionUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "predictor":
                        return(new Tag <Predictor> {
                            TypedValue = Predictor.FromKey(ushort.Parse(numberValue))
                        });

                    case "cleanfaxdata":
                        return(new Tag <CleanFaxData> {
                            TypedValue = CleanFaxData.FromKey(ushort.Parse(numberValue))
                        });

                    case "inkset":
                        return(new Tag <InkSet> {
                            TypedValue = InkSet.FromKey(ushort.Parse(numberValue))
                        });

                    case "extrasamples":
                        return(new Tag <ExtraSamples> {
                            TypedValue = ExtraSamples.FromKey(ushort.Parse(numberValue))
                        });

                    case "sampleformat":
                        return(new Tag <SampleFormat> {
                            TypedValue = SampleFormat.FromKey(ushort.Parse(numberValue))
                        });

                    case "indexed":
                        return(new Tag <Indexed> {
                            TypedValue = Indexed.FromKey(ushort.Parse(numberValue))
                        });

                    case "opiproxy":
                        return(new Tag <OpiProxy> {
                            TypedValue = OpiProxy.FromKey(ushort.Parse(numberValue))
                        });

                    case "profiletype":
                        return(new Tag <ProfileType> {
                            TypedValue = ProfileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "faxprofile":
                        return(new Tag <FaxProfile> {
                            TypedValue = FaxProfile.FromKey(ushort.Parse(numberValue))
                        });

                    case "jpegproc":
                        return(new Tag <JpegProc> {
                            TypedValue = JpegProc.FromKey(ushort.Parse(numberValue))
                        });

                    case "ycbcrsubsampling":
                        return(new Tag <YCbCrSubSampling> {
                            TypedValue = YCbCrSubSampling.FromKey(numberValue)
                        });

                    case "ycbcrpositioning":
                        return(new Tag <YCbCrPositioning> {
                            TypedValue = YCbCrPositioning.FromKey(ushort.Parse(numberValue))
                        });

                    case "sonyrawfiletype":
                        return(new Tag <SonyRawFileType> {
                            TypedValue = SonyRawFileType.FromKey(ushort.Parse(numberValue))
                        });

                    case "rasterpadding":
                        return(new Tag <RasterPadding> {
                            TypedValue = RasterPadding.FromKey(ushort.Parse(numberValue))
                        });

                    case "imagecolorindicator":
                        return(new Tag <ImageColorIndicator> {
                            TypedValue = ImageColorIndicator.FromKey(ushort.Parse(numberValue))
                        });

                    case "backgroundcolorindicator":
                        return(new Tag <BackgroundColorIndicator> {
                            TypedValue = BackgroundColorIndicator.FromKey(ushort.Parse(numberValue))
                        });

                    case "hcusage":
                        return(new Tag <HCUsage> {
                            TypedValue = HCUsage.FromKey(ushort.Parse(numberValue))
                        });

                    case "exposureprogram":
                        return(new Tag <ExposureProgram> {
                            TypedValue = ExposureProgram.FromKey(ushort.Parse(numberValue))
                        });

                    case "sensitivitytype":
                        return(new Tag <SensitivityType> {
                            TypedValue = SensitivityType.FromKey(ushort.Parse(numberValue))
                        });

                    case "componentsconfiguration":
                        return(new Tag <ComponentsConfiguration> {
                            TypedValue = ComponentsConfiguration.FromKey(ushort.Parse(numberValue))
                        });

                    case "meteringmode":
                        return(new Tag <MeteringMode> {
                            TypedValue = MeteringMode.FromKey(ushort.Parse(numberValue))
                        });

                    case "lightsource":
                    case "calibrationilluminant1":
                    case "calibrationilluminant2":
                        return(new Tag <LightSource> {
                            TypedValue = LightSource.FromKey(ushort.Parse(numberValue))
                        });

                    case "flash":
                        return(new Tag <FlashValue> {
                            TypedValue = FlashValue.FromKey(ushort.Parse(numberValue))
                        });

                    case "focalplaneresolutionunit":
                        return(new Tag <FocalPlaneResolutionUnit> {
                            TypedValue = FocalPlaneResolutionUnit.FromKey(ushort.Parse(numberValue))
                        });

                    case "securityclassification":
                        return(new Tag <SecurityClassification> {
                            TypedValue = SecurityClassification.FromKey(numberValue)
                        });

                    case "sensingmethod":
                        return(new Tag <SensingMethod> {
                            TypedValue = SensingMethod.FromKey(ushort.Parse(numberValue))
                        });

                    case "colorspace":
                        return(new Tag <ColorSpace> {
                            TypedValue = ColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "filesource":
                        return(new Tag <FileSource> {
                            TypedValue = FileSource.FromKey(ushort.Parse(numberValue))
                        });

                    case "scenetype":
                        return(new Tag <SceneType> {
                            TypedValue = SceneType.FromKey(ushort.Parse(numberValue))
                        });

                    case "customrendered":
                        return(new Tag <CustomRendered> {
                            TypedValue = CustomRendered.FromKey(ushort.Parse(numberValue))
                        });

                    case "exposuremode":
                        return(new Tag <ExposureMode> {
                            TypedValue = ExposureMode.FromKey(ushort.Parse(numberValue))
                        });

                    case "whitebalance":
                        return(new Tag <WhiteBalance> {
                            TypedValue = WhiteBalance.FromKey(ushort.Parse(numberValue))
                        });

                    case "scenecapturetype":
                        return(new Tag <SceneCaptureType> {
                            TypedValue = SceneCaptureType.FromKey(ushort.Parse(numberValue))
                        });

                    case "gaincontrol":
                        return(new Tag <GainControl> {
                            TypedValue = GainControl.FromKey(ushort.Parse(numberValue))
                        });

                    case "contrast":
                        return(new Tag <Contrast> {
                            TypedValue = Contrast.FromKey(ushort.Parse(numberValue))
                        });

                    case "saturation":
                        return(new Tag <Saturation> {
                            TypedValue = Saturation.FromKey(ushort.Parse(numberValue))
                        });

                    case "sharpness":
                        return(new Tag <Sharpness> {
                            TypedValue = Sharpness.FromKey(ushort.Parse(numberValue))
                        });

                    case "subjectdistancerange":
                        return(new Tag <SubjectDistanceRange> {
                            TypedValue = SubjectDistanceRange.FromKey(ushort.Parse(numberValue))
                        });

                    case "pixelformat":
                        return(new Tag <PixelFormat> {
                            TypedValue = PixelFormat.FromKey(ushort.Parse(numberValue))
                        });

                    case "transformation":
                        return(new Tag <Transformation> {
                            TypedValue = Transformation.FromKey(ushort.Parse(numberValue))
                        });

                    case "uncompressed":
                        return(new Tag <Uncompressed> {
                            TypedValue = Uncompressed.FromKey(ushort.Parse(numberValue))
                        });

                    case "imagedatadiscard":
                        return(new Tag <ImageDataDiscard> {
                            TypedValue = ImageDataDiscard.FromKey(ushort.Parse(numberValue))
                        });

                    case "alphadatadiscard":
                        return(new Tag <AlphaDataDiscard> {
                            TypedValue = AlphaDataDiscard.FromKey(ushort.Parse(numberValue))
                        });

                    case "usptooriginalcontenttype":
                        return(new Tag <USPTOOriginalContentType> {
                            TypedValue = USPTOOriginalContentType.FromKey(ushort.Parse(numberValue))
                        });

                    case "cfalayout":
                        return(new Tag <CFALayout> {
                            TypedValue = CFALayout.FromKey(ushort.Parse(numberValue))
                        });

                    case "makernotesafety":
                        return(new Tag <MakerNoteSafety> {
                            TypedValue = MakerNoteSafety.FromKey(ushort.Parse(numberValue))
                        });

                    case "profileembedpolicy":
                        return(new Tag <ProfileEmbedPolicy> {
                            TypedValue = ProfileEmbedPolicy.FromKey(ushort.Parse(numberValue))
                        });

                    case "previewcolorspace":
                        return(new Tag <PreviewColorSpace> {
                            TypedValue = PreviewColorSpace.FromKey(ushort.Parse(numberValue))
                        });

                    case "profilehuesatmapencoding":
                        return(new Tag <ProfileHueSatMapEncoding> {
                            TypedValue = ProfileHueSatMapEncoding.FromKey(ushort.Parse(numberValue))
                        });

                    case "profilelooktableencoding":
                        return(new Tag <ProfileLookTableEncoding> {
                            TypedValue = ProfileLookTableEncoding.FromKey(ushort.Parse(numberValue))
                        });

                    case "defaultblackrender":
                        return(new Tag <DefaultBlackRender> {
                            TypedValue = DefaultBlackRender.FromKey(ushort.Parse(numberValue))
                        });
                    }
                }

                // ---- VALUE TAG ----
                if (string.IsNullOrEmpty(info.ValueType))
                {
                    return(new Tag());
                }

                switch (info.ValueType.ToLower())
                {
                case "int8u":
                    return(new Tag <byte> {
                        TypedValue = byte.Parse(numberValue)
                    });

                case "int8s":
                    return(new Tag <sbyte> {
                        TypedValue = sbyte.Parse(numberValue)
                    });

                case "int16u":
                    return(new Tag <ushort> {
                        TypedValue = ushort.Parse(numberValue)
                    });

                case "int16s":
                    return(new Tag <short> {
                        TypedValue = short.Parse(numberValue)
                    });

                case "int32u":
                    return(new Tag <uint> {
                        TypedValue = uint.Parse(numberValue)
                    });

                case "integer":
                case "int32s":
                    return(new Tag <int> {
                        TypedValue = int.Parse(numberValue)
                    });

                case "int64u":
                    return(new Tag <ulong> {
                        TypedValue = ulong.Parse(numberValue)
                    });

                case "int64s":
                    return(new Tag <long> {
                        TypedValue = long.Parse(numberValue)
                    });

                case "float":
                case "rational32s":
                case "rational32u":
                    return(new Tag <float> {
                        TypedValue = float.Parse(numberValue)
                    });

                case "double":
                case "rational":
                case "rational64s":
                case "rational64u":
                case "real":
                    return(new Tag <double> {
                        TypedValue = double.Parse(numberValue)
                    });

                case "boolean":
                    return(new Tag <bool> {
                        TypedValue = bool.Parse(numberValue)
                    });
                }
            }
            catch
            {
                if (!Quiet)
                {
                    Console.WriteLine($"error converting {info.TableName}::{info.Id} with name {info.Name}.  Expected type: {info.ValueType} but got value: {numberValue}");
                }
            }

            return(new Tag());
        }
コード例 #14
0
        public async Task <Response> UpdatePositionDriver(Plugin.Geolocator.Abstractions.Position position, GpsStatus gpsStatus)
        {
            if (position == null || Driver.Current == null)
            {
                return(null);
            }
            var url = BaseUrl + "mobile/driverinfoupdate.php";
            List <KeyValuePair <string, string> > data = new List <KeyValuePair <string, string> >();

            data.Add(new KeyValuePair <string, string>("driverid", Driver.Current.Id.ToString()));
            data.Add(new KeyValuePair <string, string>("svendorid", Driver.Current.VendorId.ToString()));
            data.Add(new KeyValuePair <string, string>("longitude", position.Longitude.ToString()));
            data.Add(new KeyValuePair <string, string>("latitude", position.Latitude.ToString()));
            data.Add(new KeyValuePair <string, string>("status", ((int)Driver.Current.DriverStatus).ToString()));
            data.Add(new KeyValuePair <string, string>("zone", Driver.Current.Zone.ToString()));
            data.Add(new KeyValuePair <string, string>("errorstatus", ((int)gpsStatus).ToString()));
            data.Add(new KeyValuePair <string, string>("secretkey", Driver.Current.SecretKey));
            return(await MakePostRequestUrlEncodedAsync <Response>(url, data));;
        }
コード例 #15
0
        public Boolean AnalysisData(string strOrgData)
        {
            // 检查数据长度
            if (strOrgData == string.Empty)
            {
                _strErrorMsg = "RMC信息为空值";
                return false;
            }

            // 检查数据头
            if ((strOrgData.StartsWith("$GPRMC") == false) &&
                (strOrgData.StartsWith("GPRMC") == false))
            {
                _strErrorMsg = "RMC信息头错误";
                return false;
            }

            // 拆分信息
            string[] strMsgItems = strOrgData.Split(',');
            if (strMsgItems.Length != 13)
            {
                _strErrorMsg = "RMC信息条目错误";
                return false;
            }

            // 解析消息
            try
            {
                // 解析日期及时间
                _strLocalTime = GPSFunctions.ParseDateTime(strMsgItems[9], strMsgItems[1]);

                // 解析GPS状态, 判断是否定位
                if (strMsgItems[2] == "V")
                {
                    _gsStatus = GpsStatus.UnPosition;
                    _strErrorMsg = "GPS未定位";
                    return false;
                }
                else
                {
                    _gsStatus = GpsStatus.Non_DiffPosition;
                }

                // 解析纬度
                _strLatitude = GPSFunctions.ParseLatitudeAndLongitude(strMsgItems[4], strMsgItems[3]);

                // 解析经度
                _strLongitude = GPSFunctions.ParseLatitudeAndLongitude(strMsgItems[6], strMsgItems[5]);

                // 解析速度
                _dSpeed = GPSFunctions.ParseSpeed(strMsgItems[7]);

                // 解析定位角
                _nPosAngle = Int32.Parse((strMsgItems[8] == "") ? "0" : strMsgItems[8]);

                // 解析磁偏角
                _nMagDeclination = Int32.Parse((strMsgItems[10] == "") ? "0" : strMsgItems[10]);
                _drMagDeclination = ((strMsgItems[11] == "E") ? Direction.East : Direction.West);

                // 解析校验码
                _strVerify = strMsgItems[12];
            }
            catch
            {

            }

            // 默认返回false
            _strErrorMsg = null;
            return true;
        }
コード例 #16
0
 protected virtual void OnGpsStatusChanged(GpsStatus e)
 {
     GpsStatusEvent?.Invoke(this, e);
 }
コード例 #17
0
        public void Trace(GeoData raw, GeoData corrected, GpsStatus gpsStatus, DateTime computerDateTime, RoutepointExtension rteptExtension)
        {
            if (raw == null)
            {
                Log.Warn().Message("raw est null").Write(); return;
            }
            if (corrected == null)
            {
                Log.Warn().Message("corrected est null").Write(); return;
            }

            if (raw.PositionData == null)
            {
                Log.Warn().Message("raw.PositionData est null").Write(); return;
            }
            if (raw.VelocityData == null)
            {
                Log.Warn().Message("raw.VelocityData est null").Write(); return;
            }

            if (corrected.PositionData == null)
            {
                Log.Warn().Message("corrected.PositionData est null").Write(); return;
            }
            if (corrected.VelocityData == null)
            {
                Log.Warn().Message("corrected.VelocityData est null").Write(); return;
            }

            if (_output != null && (_output.WriteState == WriteState.Closed || _output.WriteState == WriteState.Error))
            {
                Log.Warn().Message("Le fichier de trace est fermé ou en erreur.").Write(); return;
            }

            _output.WriteStartElement("rtept");
            {
                _output.WriteAttributeString("lat", Convert.ToString(raw.PositionData.Latitude, CultureInfo.InvariantCulture));
                _output.WriteAttributeString("lon", Convert.ToString(raw.PositionData.Longitude, CultureInfo.InvariantCulture));

                _output.WriteElementString("time", raw.PositionData.Utc.ToString("yyyy-MM-ddTHH:mm:ss.ffK"));
                _output.WriteElementString("ele", Convert.ToString(raw.PositionData.Altitude, CultureInfo.InvariantCulture));
                _output.WriteElementString("geoidheight", Convert.ToString(raw.PositionData.GeoIdHeight, CultureInfo.InvariantCulture));
                _output.WriteElementString("fix", GpxConvert.FromFixType(raw.PositionData.Quality));
                _output.WriteElementString("sat", Convert.ToString(raw.PositionData.NbSatellites, CultureInfo.InvariantCulture));

                if (raw.PrecisionData != null)
                {
                    if (raw.PrecisionData.Hdop != null)
                    {
                        _output.WriteElementString("hdop", Convert.ToString(raw.PrecisionData.Hdop, CultureInfo.InvariantCulture));
                    }

                    if (raw.PrecisionData.Vdop != null)
                    {
                        _output.WriteElementString("vdop", Convert.ToString(raw.PrecisionData.Vdop, CultureInfo.InvariantCulture));
                    }

                    if (raw.PrecisionData.Pdop != null)
                    {
                        _output.WriteElementString("pdop", Convert.ToString(raw.PrecisionData.Pdop, CultureInfo.InvariantCulture));
                    }
                }

                _output.WriteElementString("ageofdgpsdata", Convert.ToString(raw.PositionData.DifferentialDataAge, CultureInfo.InvariantCulture));
                _output.WriteElementString("dgpsid", Convert.ToString(raw.PositionData.DifferentialStationId));

                _output.WriteStartElement("extensions");
                {
                    _output.WriteElementString("computerDateTime", computerDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fffffffK"));

                    _output.WriteStartElement("CorrectedPositionValue");
                    {
                        _output.WriteElementString("lat", Convert.ToString(corrected.PositionData.Latitude, CultureInfo.InvariantCulture));
                        _output.WriteElementString("lon", Convert.ToString(corrected.PositionData.Longitude, CultureInfo.InvariantCulture));
                    }
                    _output.WriteEndElement();

                    _output.WriteElementString("gpsStatus", Convert.ToString(gpsStatus));
                    _output.WriteElementString("speedKmh", Convert.ToString(raw.VelocityData.SpeedKmh, CultureInfo.InvariantCulture));

                    if (rteptExtension != null)
                    {
                        if (rteptExtension.Progress.HasValue)
                        {
                            _output.WriteElementString("progress", Convert.ToString(rteptExtension.Progress.Value, CultureInfo.InvariantCulture));
                        }
                    }

                    if (raw.PositionData.InsData != null)
                    {
                        _output.WriteStartElement("ins", "inertial", null);
                        {
                            _output.WriteElementString("navigationStatus", Convert.ToString(raw.PositionData.InsData.Status, CultureInfo.InvariantCulture));
                            _output.WriteElementString("accx", Convert.ToString(raw.PositionData.InsData.AccelerationX, CultureInfo.InvariantCulture));
                            _output.WriteElementString("accy", Convert.ToString(raw.PositionData.InsData.AccelerationY, CultureInfo.InvariantCulture));
                            _output.WriteElementString("accz", Convert.ToString(raw.PositionData.InsData.AccelerationZ, CultureInfo.InvariantCulture));
                            _output.WriteElementString("angrtx", Convert.ToString(raw.PositionData.InsData.AngularRateX, CultureInfo.InvariantCulture));
                            _output.WriteElementString("angrty", Convert.ToString(raw.PositionData.InsData.AngularRateY, CultureInfo.InvariantCulture));
                            _output.WriteElementString("angrtz", Convert.ToString(raw.PositionData.InsData.AngularRateZ, CultureInfo.InvariantCulture));
                            _output.WriteElementString("nvelo", Convert.ToString(raw.PositionData.InsData.NorthVelocity, CultureInfo.InvariantCulture));
                            _output.WriteElementString("evelo", Convert.ToString(raw.PositionData.InsData.EastVelocity, CultureInfo.InvariantCulture));
                            _output.WriteElementString("dvelo", Convert.ToString(raw.PositionData.InsData.DownVelocity, CultureInfo.InvariantCulture));
                            _output.WriteElementString("heading", Convert.ToString(raw.PositionData.InsData.Heading, CultureInfo.InvariantCulture));
                            _output.WriteElementString("pitch", Convert.ToString(raw.PositionData.InsData.Pitch, CultureInfo.InvariantCulture));
                            _output.WriteElementString("roll", Convert.ToString(raw.PositionData.InsData.Roll, CultureInfo.InvariantCulture));

                            if (raw.PrecisionData != null)
                            {
                                if (raw.PrecisionData.EastPositionAccuracy != null)
                                {
                                    _output.WriteElementString("eastPositionAccuracy", Convert.ToString(raw.PrecisionData.EastPositionAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.DownPositionAccuracy != null)
                                {
                                    _output.WriteElementString("downPositionAccuracy", Convert.ToString(raw.PrecisionData.DownPositionAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.NorthPositionAccuracy != null)
                                {
                                    _output.WriteElementString("northPositionAccuracy", Convert.ToString(raw.PrecisionData.NorthPositionAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.DownVelocityAccuracy != null)
                                {
                                    _output.WriteElementString("downVelocityAccuracy", Convert.ToString(raw.PrecisionData.DownVelocityAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.EastVelocityAccuracy != null)
                                {
                                    _output.WriteElementString("eastVelocityAccuracy", Convert.ToString(raw.PrecisionData.EastVelocityAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.NorthVelocityAccuracy != null)
                                {
                                    _output.WriteElementString("northVelocityAccuracy", Convert.ToString(raw.PrecisionData.NorthVelocityAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.HeadingAccuracy != null)
                                {
                                    _output.WriteElementString("headingAccuracy", Convert.ToString(raw.PrecisionData.HeadingAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.PitchAccuracy != null)
                                {
                                    _output.WriteElementString("pitchAccuracy", Convert.ToString(raw.PrecisionData.PitchAccuracy, CultureInfo.InvariantCulture));
                                }

                                if (raw.PrecisionData.RollAccuracy != null)
                                {
                                    _output.WriteElementString("rollAccuracy", Convert.ToString(raw.PrecisionData.RollAccuracy, CultureInfo.InvariantCulture));
                                }
                            }
                        }
                        _output.WriteEndElement();
                    }
                }
                _output.WriteEndElement();
            }
            _output.WriteEndElement();
        }
コード例 #18
0
        public Boolean AnalysisData(string strOrgData)
        {
            // 检查数据长度
            if (strOrgData == string.Empty)
            {
                _strErrorMsg = "RMC信息为空值";
                return(false);
            }

            // 检查数据头
            if ((strOrgData.StartsWith("$GPRMC") == false) &&
                (strOrgData.StartsWith("GPRMC") == false))
            {
                _strErrorMsg = "RMC信息头错误";
                return(false);
            }

            // 拆分信息
            string[] strMsgItems = strOrgData.Split(',');
            if (strMsgItems.Length != 13)
            {
                _strErrorMsg = "RMC信息条目错误";
                return(false);
            }

            // 解析消息
            try
            {
                // 解析日期及时间
                _strLocalTime = GPSFunctions.ParseDateTime(strMsgItems[9], strMsgItems[1]);

                // 解析GPS状态, 判断是否定位
                if (strMsgItems[2] == "V")
                {
                    _gsStatus    = GpsStatus.UnPosition;
                    _strErrorMsg = "GPS未定位";
                    return(false);
                }
                else
                {
                    _gsStatus = GpsStatus.Non_DiffPosition;
                }

                // 解析纬度
                _strLatitude = GPSFunctions.ParseLatitudeAndLongitude(strMsgItems[4], strMsgItems[3]);

                // 解析经度
                _strLongitude = GPSFunctions.ParseLatitudeAndLongitude(strMsgItems[6], strMsgItems[5]);

                // 解析速度
                _dSpeed = GPSFunctions.ParseSpeed(strMsgItems[7]);

                // 解析定位角
                _nPosAngle = Int32.Parse((strMsgItems[8] == "") ? "0" : strMsgItems[8]);

                // 解析磁偏角
                _nMagDeclination  = Int32.Parse((strMsgItems[10] == "") ? "0" : strMsgItems[10]);
                _drMagDeclination = ((strMsgItems[11] == "E") ? Direction.East : Direction.West);

                // 解析校验码
                _strVerify = strMsgItems[12];
            }
            catch
            {
            }

            // 默认返回false
            _strErrorMsg = null;
            return(true);
        }