Exemple #1
0
        protected override void RunActualProcess()
        {
            var dbRaw   = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice);
            var dbHouse = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, Constants.PresentSlice);

            dbHouse.Execute("DELETE FROM HouseOsmMatch where MatchType ='" + (int)MatchType.SonnendachDirect + "'");
            dbHouse.Execute("DELETE FROM HouseOsmMatch where MatchType ='" + (int)MatchType.SonnedachClosest + "'");
            var osmFeatures = dbRaw.Fetch <OsmFeature>();
            var sonnendach  = dbRaw.Fetch <B05_SonnendachGeoJson>();

            dbHouse.BeginTransaction();
            var repository = new MapTileRepository(osmFeatures);

            foreach (var sonnendachEntry in sonnendach)
            {
                if (sonnendachEntry.WgsPoints.Count == 0)
                {
                    throw new Exception("No wgs points in Sonnendach");
                }

                var pointsToLookFor = sonnendachEntry.WgsPoints.Where(x => repository.BoundingBoxAllFeatures.IsInside(x)).ToList();
                if (pointsToLookFor.Count == 0)
                {
                    //points outside of osm
                    continue;
                }

                var    matchingOsms = repository.FindDirectlyMatchingFeatures(pointsToLookFor);
                var    mt           = MatchType.SonnendachDirect;
                double distance     = 0;
                if (matchingOsms.Count == 0)
                {
                    var closestFeature = repository.FindBestDistanceMatch(pointsToLookFor, out var closestPoint, out distance);
                    matchingOsms.Add(closestFeature);
                    mt = MatchType.SonnedachClosest;
                    var point = closestPoint;
                    point.Size  = 10;
                    point.Label = "blub";
                    point.Rgb   = Constants.Türkis;
                    //notDirectHits.Add(point);
                }

                foreach (var feature in matchingOsms)
                {
                    var hom = new HouseOsmMatch(sonnendachEntry.Guid, feature.Guid, mt, distance);
                    dbHouse.Save(hom);
                }
            }

            dbHouse.CompleteTransaction();
        }
        protected override void RunActualProcess()
        {
            var dbRaw   = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Raw, Constants.PresentSlice);
            var dbHouse = Services.SqlConnectionPreparer.GetDatabaseConnection(Stage.Houses, Constants.PresentSlice);

            dbHouse.Execute("DELETE FROM HouseOsmMatch where MatchType = " + (int)MatchType.LocalnetClosest);
            dbHouse.Execute("DELETE FROM HouseOsmMatch where MatchType = " + (int)MatchType.LocalnetMatch);


            var osmFeatures = dbRaw.Fetch <OsmFeature>();
            var houses      = dbHouse.Fetch <House>();

            var repository = new MapTileRepository(osmFeatures);

            dbHouse.BeginTransaction();
            foreach (var house in houses)
            {
                //find gwr entries matching the house
                //var gwrEntries = gwr.Where(x => house.EGIDs.Contains(x.EidgGebaeudeidentifikator_EGID ?? 0));
                var filteredPoints = house.LocalWgsPoints.Where(x => repository.BoundingBoxAllFeatures.IsInside(x)).ToList();
                if (filteredPoints.Count == 0)
                {
                    continue;
                }

                var    matchingOsms = repository.FindDirectlyMatchingFeatures(filteredPoints);
                var    matchType    = MatchType.LocalnetMatch;
                double distance     = 0;
                if (matchingOsms.Count == 0)
                {
                    var closestFeature = repository.FindBestDistanceMatch(filteredPoints, out var closestPoint, out distance);
                    matchType = MatchType.LocalnetClosest;
                    matchingOsms.Add(closestFeature);
                    var point = closestPoint;
                    point.Size  = 10;
                    point.Label = "blub";
                    point.Rgb   = Constants.Türkis;
                    _notDirectHits.Add(point);
                }

                foreach (var feature in matchingOsms)
                {
                    var hom = new HouseOsmMatch(house.Guid, feature.Guid, matchType, distance);
                    dbHouse.Save(hom);
                }
            }

            dbHouse.CompleteTransaction();
        }