Beispiel #1
0
        private void FilterEarthquake()
        {
            FilteredQueryResults.Clear();

            Proj4Projection mercatorToWgs84Projection = new Proj4Projection();

            mercatorToWgs84Projection.InternalProjectionParametersString = Proj4Projection.GetSphericalMercatorParametersString();
            mercatorToWgs84Projection.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
            mercatorToWgs84Projection.Open();

            for (int i = queryResults.Count - 1; i >= 0; i--)
            {
                EarthquakeViewModel resultItem = queryResults[i];

                double latitude, longitude;
                if (double.TryParse(resultItem.Latitude, out latitude) && double.TryParse(resultItem.Longitude, out longitude))
                {
                    PointShape point = new PointShape(longitude, latitude);
                    point = (PointShape)mercatorToWgs84Projection.ConvertToExternalProjection(point);

                    EarthquakeViewModel newResultItem = new EarthquakeViewModel(resultItem.EpicenterFeature);
                    newResultItem.Latitude  = point.Y.ToString("f3", CultureInfo.InvariantCulture);
                    newResultItem.Longitude = point.X.ToString("f3", CultureInfo.InvariantCulture);

                    double year, depth, magnitude;
                    double.TryParse(newResultItem.Magnitude, out magnitude);
                    double.TryParse(newResultItem.DepthInKilometer, out depth);
                    double.TryParse(newResultItem.Year, out year);

                    if ((magnitude >= queryFilter.StartMagnitudeRange && magnitude <= queryFilter.EndMagnitudeRange || newResultItem.Magnitude == Resources.UnknownString) &&
                        (depth <= queryFilter.EndDepthRange && depth >= queryFilter.StartDepthRange || newResultItem.DepthInKilometer == Resources.UnknownString) &&
                        (year >= queryFilter.StartYearRange && year <= queryFilter.EndYearRange) || newResultItem.Year == Resources.UnknownString)
                    {
                        FilteredQueryResults.Add(newResultItem);
                    }
                }
            }

            mercatorToWgs84Projection.Close();
            mapModel.RefreshMarkersByFeatures(FilteredQueryResults.Select(f => f.EpicenterFeature));
        }
        private void FilterEarthquake()
        {
            FilteredQueryResults.Clear();

            ManagedProj4Projection mercatorToWgs84Projection = new ManagedProj4Projection();
            mercatorToWgs84Projection.InternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();
            mercatorToWgs84Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
            mercatorToWgs84Projection.Open();

            for (int i = queryResults.Count - 1; i >= 0; i--)
            {
                EarthquakeViewModel resultItem = queryResults[i];

                double latitude, longitude;
                if (double.TryParse(resultItem.Latitude, out latitude) && double.TryParse(resultItem.Longitude, out longitude))
                {
                    PointShape point = new PointShape(longitude, latitude);
                    point = (PointShape)mercatorToWgs84Projection.ConvertToExternalProjection(point);

                    EarthquakeViewModel newResultItem = new EarthquakeViewModel(resultItem.EpicenterFeature);
                    newResultItem.Latitude = point.Y.ToString("f3", CultureInfo.InvariantCulture);
                    newResultItem.Longitude = point.X.ToString("f3", CultureInfo.InvariantCulture);

                    double year, depth, magnitude;
                    double.TryParse(newResultItem.Magnitude, out magnitude);
                    double.TryParse(newResultItem.DepthInKilometer, out depth);
                    double.TryParse(newResultItem.Year, out year);

                    if ((magnitude >= queryFilter.StartMagnitudeRange && magnitude <= queryFilter.EndMagnitudeRange || newResultItem.Magnitude == Resources.UnknownString)
                        && (depth <= queryFilter.EndDepthRange && depth >= queryFilter.StartDepthRange || newResultItem.DepthInKilometer == Resources.UnknownString)
                        && (year >= queryFilter.StartYearRange && year <= queryFilter.EndYearRange) || newResultItem.Year == Resources.UnknownString)
                    {
                        FilteredQueryResults.Add(newResultItem);
                    }
                }
            }

            mercatorToWgs84Projection.Close();
            mapModel.RefreshMarkersByFeatures(FilteredQueryResults.Select(f => f.EpicenterFeature));
        }