Beispiel #1
0
        public IEnumerable <INatureAreaGeoJson> GetNatureAreasBySearchFilter(SearchFilterRequest searchFilterRequest)
        {
            int natureAreaCount;
            var natureAreas = GetNatureAreasBySearchFilter(
                searchFilterRequest.AnalyzeSearchFilterRequest(),
                searchFilterRequest.NatureAreaTypeCodes,
                searchFilterRequest.DescriptionVariableCodes,
                searchFilterRequest.Municipalities,
                searchFilterRequest.Counties,
                searchFilterRequest.ConservationAreas,
                searchFilterRequest.Institutions,
                searchFilterRequest.RedlistAssessmentUnits,
                searchFilterRequest.RedlistCategories,
                searchFilterRequest.Geometry,
                searchFilterRequest.BoundingBox,
                searchFilterRequest.EpsgCode,
                searchFilterRequest.CenterPoints,
                0,
                0,
                int.MaxValue,
                out natureAreaCount
                );

            return(natureAreas);
        }
        private static IEnumerable <Metadata> FindMetadatasBySearchFilter(SearchFilterRequest searchFilterRequest)
        {
            var natureLevels = searchFilterRequest.AnalyzeSearchFilterRequest();

            return(SqlServer.GetMetadatasBySearchFilter(
                       natureLevels,
                       searchFilterRequest.NatureAreaTypeCodes,
                       searchFilterRequest.DescriptionVariableCodes,
                       searchFilterRequest.Municipalities,
                       searchFilterRequest.Counties,
                       searchFilterRequest.ConservationAreas,
                       searchFilterRequest.Institutions,
                       searchFilterRequest.Geometry,
                       "",
                       searchFilterRequest.EpsgCode
                       ));
        }
Beispiel #3
0
        private static IEnumerable <Metadata> FindMetadatasBySearchFilter(SearchFilterRequest searchFilterRequest)
        {
            var natureLevels = searchFilterRequest.AnalyzeSearchFilterRequest();

            var search = new SearchV2(Config.Settings.ConnectionString);

            return(search.GetMetadatasBySearchFilter(
                       natureLevels,
                       searchFilterRequest.NatureAreaTypeCodes,
                       searchFilterRequest.DescriptionVariableCodes,
                       searchFilterRequest.Municipalities,
                       searchFilterRequest.Counties,
                       searchFilterRequest.ConservationAreas,
                       searchFilterRequest.Institutions,
                       searchFilterRequest.RedlistAssessmentUnits,
                       searchFilterRequest.RedlistCategories,
                       searchFilterRequest.Geometry,
                       string.Empty,
                       searchFilterRequest.EpsgCode
                       ));
        }
Beispiel #4
0
        public object GetNatureAreaStatisticsBySearchFilter([FromBody] SearchFilterRequest request)
        {
            var natureLevels = request.AnalyzeSearchFilterRequest();
            int natureAreaCount;

            var search = new SearchV2(Config.Settings.ConnectionString);

            var natureAreas = search.GetNatureAreasBySearchFilter(
                natureLevels,
                request.NatureAreaTypeCodes,
                request.DescriptionVariableCodes,
                request.Municipalities,
                request.Counties,
                request.ConservationAreas,
                request.Institutions,
                request.RedlistAssessmentUnits,
                request.RedlistCategories,
                request.Geometry,
                "",
                request.EpsgCode,
                true,
                1,
                0,
                int.MaxValue,
                out natureAreaCount
                );

            var institutions  = new Dictionary <string, int>();
            var surveyedYears = new Dictionary <int, int>();

            var typecastedNatureAreas = natureAreas.Select(na => (NatureArea)na);

            foreach (var natureArea in typecastedNatureAreas)
            {
                if (institutions.ContainsKey(natureArea.Institution))
                {
                    institutions[natureArea.Institution]++;
                }
                else
                {
                    institutions[natureArea.Institution] = 1;
                }
                if (!natureArea.Surveyed.HasValue)
                {
                    continue;
                }
                if (surveyedYears.ContainsKey(natureArea.Surveyed.Value.Year))
                {
                    surveyedYears[natureArea.Surveyed.Value.Year]++;
                }
                else
                {
                    surveyedYears[natureArea.Surveyed.Value.Year] = 1;
                }
            }

            var natureAreaTypeHash = new CodeIds();

            foreach (var natureArea in typecastedNatureAreas)
            {
                foreach (var parameter in natureArea.Parameters)
                {
                    var natureAreaType = parameter as NatureAreaType;
                    if (natureAreaType != null)
                    {
                        natureAreaTypeHash.Add(natureAreaType, natureArea);
                    }
                }
            }

            var natureAreaTypeSummary = GetCodeSummaryHierarchy(natureAreaTypeHash, Naturkodetrær.Naturtyper);

            var natureAreaStatistics = new NatureAreaStatistics {
                NatureAreaTypes = natureAreaTypeSummary
            };

            foreach (var institution in institutions)
            {
                natureAreaStatistics.Institutions.Add(new NatureAreaSummaryItem
                {
                    Name            = institution.Key,
                    NatureAreaCount = institution.Value
                });
            }
            foreach (var surveyYear in surveyedYears)
            {
                natureAreaStatistics.SurveyYears.Add(new NatureAreaSurveyYearSummaryItem
                {
                    Year            = surveyYear.Key,
                    NatureAreaCount = surveyYear.Value
                });
            }

            var natureAreaStatisticsJson = JObject.FromObject(natureAreaStatistics);

            RemoveFields(natureAreaStatisticsJson, "HandledIds", true);
            if (natureAreaStatisticsJson.First == null)
            {
                return(natureAreaStatisticsJson);
            }

            RemoveFields(natureAreaStatisticsJson.First.First, "Name", false);
            RemoveFields(natureAreaStatisticsJson.First.First, "Url", false);
            RemoveFields(natureAreaStatisticsJson.First.First, "Count", false);

            return(natureAreaStatisticsJson);
        }
Beispiel #5
0
        public NatureAreaList GetNatureAreaInfosBySearchFilter([FromBody] SearchFilterRequest request)
        {
            var natureLevels = request.AnalyzeSearchFilterRequest();

            var search = new SearchV2(Config.Settings.ConnectionString);

            int natureAreaCount;
            var natureAreas = search.GetNatureAreasBySearchFilter(
                natureLevels,
                request.NatureAreaTypeCodes,
                request.DescriptionVariableCodes,
                request.Municipalities,
                request.Counties,
                request.ConservationAreas,
                request.Institutions,
                request.RedlistAssessmentUnits,
                request.RedlistCategories,
                request.Geometry,
                "",
                request.EpsgCode,
                true,
                2,
                request.IndexFrom,
                request.IndexTo,
                out natureAreaCount
                );

            var natureAreaList = new NatureAreaList {
                NatureAreaCount = natureAreaCount
            };

            foreach (var natureArea in natureAreas)
            {
                var natureAreaExport = (NatureAreaExport)natureArea;
                AddCodeHierarchyInfo(natureAreaExport.Parameters);

                var natureAreaListItem = new NatureAreaListItem {
                    LocalId = natureAreaExport.UniqueId.LocalId
                };

                var natureLevelCode = Naturkodetrær.Naturtyper.HentFraKode(natureAreaExport.Nivå);
                if (natureLevelCode != null)
                {
                    natureAreaListItem.NatureLevelCode        = natureLevelCode.Id;
                    natureAreaListItem.NatureLevelDescription = natureLevelCode.Name;
                    natureAreaListItem.NatureLevelUrl         = natureLevelCode.Url;
                }

                natureAreaListItem.Parameters = natureAreaExport.Parameters;
                HandleCustomVariables(natureAreaListItem.Parameters, natureArea.UniqueId.LocalId);

                natureAreaListItem.SurveyScale = natureAreaExport.MetadataSurveyScale;
                if (natureAreaExport.Surveyed.HasValue)
                {
                    natureAreaListItem.SurveyedYear = natureAreaExport.Surveyed.Value.Year;
                }

                natureAreaListItem.Contractor = natureAreaExport.MetadataContractor;
                natureAreaListItem.Surveyer   = natureAreaExport.Surveyer != null
                    ? natureAreaExport.Surveyer.Company
                    : "";
                natureAreaListItem.Program = natureAreaExport.MetadataProgram;
                natureAreaList.NatureAreas.Add(natureAreaListItem);
            }

            //var natureAreaListItemsJson = JsonConvert.SerializeObject(natureAreaList, jsonSerializerSettings);
            //return natureAreaListItemsJson;
            return(natureAreaList);
        }