public override byte[] AsBinary(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var providerValue = new MySqlGeometry();
              MySqlGeometry.TryParse(geometryValue.ProviderValue.ToString(), out providerValue);

              return providerValue.Value;
        }
        /// <summary>
        ///     Parsing the THREEJS Geometry of an Object ... (including the color ...)
        /// </summary>
        /// <param name="geo"></param>
        /// <param name="model"></param>
        /// <param name="color"></param>
        public static void EvaluateAndSaveGeometry(DbGeometry geo, DtObject model, Color color)
        {
            // Create 3DPoints
            var splitpointlist = geo.Vertices
                .Select((x, i) => new { Index = i, Value = x })
                .GroupBy(x => x.Index / 3)
                .Select(x => x.Select(v => v.Value).ToList())
                .ToList();

            var points = splitpointlist.Select(item => new Point3D(item[0], item[1], item[2])).ToList();

            // Add the information as AttributeGroup
            model.AttributeGroups["geometry"].AddProperty("threejspoints", points);
            model.AttributeGroups["geometry"].AddProperty("geometryindices", geo.Faces);
            model.AttributeGroups["geometry"].AddProperty("color", color);
        }
        public override DbGeometry Buffer(DbGeometry geometryValue, double distance)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              DbGeometry mysqlValue = DbGeometry.FromText(geometryValue.ProviderValue.ToString());
              return mysqlValue.Buffer(distance);
        }
Exemplo n.º 4
0
 internal DbGeometryAdapter(DbGeometry geomValue)
 {
     this.value = geomValue;
 }
Exemplo n.º 5
0
 public static double FeetToAverageLatLonDegree(DbGeometry geometry, double feet)
 {
     return(2 / ((1 / FeetToLonDegree(geometry, feet)) + (1 / FeetToLatDegree(geometry, feet)))); //Harmonic mean
 }
        public override DbGeometry InteriorRingAt(DbGeometry geometryValue, int index)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.InteriorRingAt(index);
        }
        public override DbGeometry SymmetricDifference(DbGeometry geometryValue, DbGeometry otherGeometry)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              if (otherGeometry == null)
            throw new ArgumentNullException("otherGeometry");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              var mysqlOtherValue = GeometryFromProviderValue(otherGeometry);

              return mysqlValue.SymmetricDifference(mysqlOtherValue);
        }
        public override int GetCoordinateSystemId(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.CoordinateSystemId;
        }
        public override bool GetIsValid(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.IsValid;
        }
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryPoint to be changed before returning.
 /// </summary>
 partial void GetAttrGeometryPoint(ref DbGeometry result);
Exemplo n.º 11
0
 public static String AsTextZM(DbGeometry geometryValue)
 {
     throw new NotSupportedException(Strings.ELinq_DbFunctionDirectCall);
 }
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryMultiPolygon to be changed before returning.
 /// </summary>
 partial void GetAttrGeometryMultiPolygon(ref DbGeometry result);
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryPoint to be changed before setting.
 /// </summary>
 partial void SetAttrGeometryPoint(DbGeometry oldValue, ref DbGeometry newValue);
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryMultiPolygon to be changed before setting.
 /// </summary>
 partial void SetAttrGeometryMultiPolygon(DbGeometry oldValue, ref DbGeometry newValue);
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryMultiLineString to be changed before returning.
 /// </summary>
 partial void GetAttrGeometryMultiLineString(ref DbGeometry result);
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryMultiLineString to be changed before setting.
 /// </summary>
 partial void SetAttrGeometryMultiLineString(DbGeometry oldValue, ref DbGeometry newValue);
        public override DbGeometryWellKnownValue CreateWellKnownValue(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.WellKnownValue;
        }
Exemplo n.º 18
0
 public static DbGeometry BufferWithTolerance(DbGeometry geometryValue, Double?distance, Double?tolerance, Boolean?relative)
 {
     throw new NotSupportedException(Strings.ELinq_DbFunctionDirectCall);
 }
        public override double Distance(DbGeometry geometryValue, DbGeometry otherGeometry)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              if (otherGeometry == null)
            throw new ArgumentNullException("otherGeometry");

              DbGeometry mysqlValue = DbGeometry.FromText(geometryValue.ProviderValue.ToString());

              Double? result = mysqlValue.Distance(otherGeometry);
              if (result != null)
            return result.Value;
              return 0;
        }
Exemplo n.º 20
0
 public static Boolean?InstanceOf(DbGeometry geometryValue, String geometryTypeName)
 {
     throw new NotSupportedException(Strings.ELinq_DbFunctionDirectCall);
 }
        public override DbGeometry GetExteriorRing(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.ExteriorRing;
        }
Exemplo n.º 22
0
 public static Boolean?Filter(DbGeometry geometryValue, DbGeometry geometryOther)
 {
     throw new NotSupportedException(Strings.ELinq_DbFunctionDirectCall);
 }
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryCollection to be changed before returning.
 /// </summary>
 partial void GetAttrGeometryCollection(ref DbGeometry result);
Exemplo n.º 24
0
 public static DbGeometry MakeValid(DbGeometry geometryValue)
 {
     throw new NotSupportedException(Strings.ELinq_DbFunctionDirectCall);
 }
 public override DbGeometry PointAt(DbGeometry geometryValue, int index)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 26
0
 public static DbGeometry Reduce(DbGeometry geometryValue, Double?tolerance)
 {
     throw new NotSupportedException(Strings.ELinq_DbFunctionDirectCall);
 }
 /// <summary>
 /// Public constructor with required data
 /// </summary>
 /// <param name="attrgeography"></param>
 /// <param name="attrgeographycollection"></param>
 /// <param name="attrgeographylinestring"></param>
 /// <param name="attrgeographymultilinestring"></param>
 /// <param name="attrgeographymultipoint"></param>
 /// <param name="attrgeographymultipolygon"></param>
 /// <param name="attrgeographypoint"></param>
 /// <param name="attrgeographypolygon"></param>
 /// <param name="attrgeometry"></param>
 /// <param name="attrgeometrycollection"></param>
 /// <param name="attrgeometrylinestring"></param>
 /// <param name="attrgeometrymultilinestring"></param>
 /// <param name="attrgeometrymultipoint"></param>
 /// <param name="attrgeometrymultipolygon"></param>
 /// <param name="attrgeometrypoint"></param>
 public SpatialProperties(DbGeography attrgeography, DbGeography attrgeographycollection, DbGeography attrgeographylinestring, DbGeography attrgeographymultilinestring, DbGeography attrgeographymultipoint, DbGeography attrgeographymultipolygon, DbGeography attrgeographypoint, DbGeography attrgeographypolygon, DbGeometry attrgeometry, DbGeometry attrgeometrycollection, DbGeometry attrgeometrylinestring, DbGeometry attrgeometrymultilinestring, DbGeometry attrgeometrymultipoint, DbGeometry attrgeometrymultipolygon, DbGeometry attrgeometrypoint)
 {
     if (attrgeography == null)
     {
         throw new ArgumentNullException(nameof(attrgeography));
     }
     this.AttrGeography = attrgeography;
     if (attrgeographycollection == null)
     {
         throw new ArgumentNullException(nameof(attrgeographycollection));
     }
     this.AttrGeographyCollection = attrgeographycollection;
     if (attrgeographylinestring == null)
     {
         throw new ArgumentNullException(nameof(attrgeographylinestring));
     }
     this.AttrGeographyLineString = attrgeographylinestring;
     if (attrgeographymultilinestring == null)
     {
         throw new ArgumentNullException(nameof(attrgeographymultilinestring));
     }
     this.AttrGeographyMultiLineString = attrgeographymultilinestring;
     if (attrgeographymultipoint == null)
     {
         throw new ArgumentNullException(nameof(attrgeographymultipoint));
     }
     this.AttrGeographyMultiPoint = attrgeographymultipoint;
     if (attrgeographymultipolygon == null)
     {
         throw new ArgumentNullException(nameof(attrgeographymultipolygon));
     }
     this.AttrGeographyMultiPolygon = attrgeographymultipolygon;
     if (attrgeographypoint == null)
     {
         throw new ArgumentNullException(nameof(attrgeographypoint));
     }
     this.AttrGeographyPoint = attrgeographypoint;
     if (attrgeographypolygon == null)
     {
         throw new ArgumentNullException(nameof(attrgeographypolygon));
     }
     this.AttrGeographyPolygon = attrgeographypolygon;
     if (attrgeometry == null)
     {
         throw new ArgumentNullException(nameof(attrgeometry));
     }
     this.AttrGeometry = attrgeometry;
     if (attrgeometrycollection == null)
     {
         throw new ArgumentNullException(nameof(attrgeometrycollection));
     }
     this.AttrGeometryCollection = attrgeometrycollection;
     if (attrgeometrylinestring == null)
     {
         throw new ArgumentNullException(nameof(attrgeometrylinestring));
     }
     this.AttrGeometryLineString = attrgeometrylinestring;
     if (attrgeometrymultilinestring == null)
     {
         throw new ArgumentNullException(nameof(attrgeometrymultilinestring));
     }
     this.AttrGeometryMultiLineString = attrgeometrymultilinestring;
     if (attrgeometrymultipoint == null)
     {
         throw new ArgumentNullException(nameof(attrgeometrymultipoint));
     }
     this.AttrGeometryMultiPoint = attrgeometrymultipoint;
     if (attrgeometrymultipolygon == null)
     {
         throw new ArgumentNullException(nameof(attrgeometrymultipolygon));
     }
     this.AttrGeometryMultiPolygon = attrgeometrymultipolygon;
     if (attrgeometrypoint == null)
     {
         throw new ArgumentNullException(nameof(attrgeometrypoint));
     }
     this.AttrGeometryPoint = attrgeometrypoint;
     Init();
 }
Exemplo n.º 28
0
 /// <summary>
 /// Constructor for building a new object with MaximalConstructor required fields in preparation for insert into database
 /// </summary>
 public Parcel(int parcelID, string parcelNumber, DbGeometry parcelGeometry, string ownerName, string parcelStreetNumber, string parcelAddress, string parcelZipCode, string landUse, int?squareFeetHome, int?squareFeetLot, double parcelAreaInAcres, DbGeometry parcelGeometry4326) : this()
 {
     this.ParcelID           = parcelID;
     this.ParcelNumber       = parcelNumber;
     this.ParcelGeometry     = parcelGeometry;
     this.OwnerName          = ownerName;
     this.ParcelStreetNumber = parcelStreetNumber;
     this.ParcelAddress      = parcelAddress;
     this.ParcelZipCode      = parcelZipCode;
     this.LandUse            = landUse;
     this.SquareFeetHome     = squareFeetHome;
     this.SquareFeetLot      = squareFeetLot;
     this.ParcelAreaInAcres  = parcelAreaInAcres;
     this.ParcelGeometry4326 = parcelGeometry4326;
 }
Exemplo n.º 29
0
 public static SqlGeometry ToSqlGeometry(this DbGeometry dbGeometry)
 {
     // Not enforcing 4326 here, but am explicitly passing through relevant starting CoordinateSystemId.
     return(SqlGeometry.STGeomFromWKB(new SqlBytes(dbGeometry.AsBinary()), dbGeometry.CoordinateSystemId));
 }
Exemplo n.º 30
0
        /// <summary>
        /// Setup for Nunit Tests.
        /// </summary>
        protected override void OnSetup()
        {
            unit1Guid = Guid.NewGuid();
            unit2Guid = Guid.NewGuid();
            unit3Guid = Guid.NewGuid();
            user1Id   = System.Guid.NewGuid();
            user2Id   = System.Guid.NewGuid();

            var unitBoundary = DbGeometry.PolygonFromText("POLYGON((511570.8590967182 106965.35195621933, 511570.8590967182 107474.95297542136, 512474.1409032818 107474.95297542136, 512474.1409032818 106965.35195621933, 511570.8590967182 106965.35195621933))", 27700);
            var location     = new List <Location>()
            {
                new Location()
                {
                    ID = unit1Guid, Shape = unitBoundary
                }
            };
            var roadName = new List <OSRoadLink>()
            {
                new OSRoadLink()
                {
                    CentreLineGeometry = unitBoundary,
                    RoadName           = "Road 001"
                }
            };

            refDataCategotyDTO = new List <ReferenceDataCategoryDTO>()
            {
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.AccessLinkType,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = null,
                            ReferenceDataValue = ReferenceDataValues.AccessLinkTypeDefault,
                            ID = Guid.Parse("4DBA7B39-D23E-493A-9B8F-B94D181A082F")
                        },

                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = null,
                            ReferenceDataValue = ReferenceDataValues.UserDefined,
                            ID = Guid.Parse("DA8F1A91-2E2B-4EEF-9A81-9B18A917CBF1")
                        }
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.AccessLinkDirection,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = null,
                            ReferenceDataValue = ReferenceDataValues.AccessLinkDirectionBoth,
                            ID = Guid.Parse("5DBA7B39-D23E-493A-9B8F-B94D181A082F")
                        }
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.AccessLinkStatus,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = null,
                            ReferenceDataValue = ReferenceDataValues.AccessLinkStatusLive,
                            ID = Guid.Parse("6DBA7B39-D23E-493A-9B8F-B94D181A082F")
                        },
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = null,
                            ReferenceDataValue = ReferenceDataValues.AccessLinkStatusDraftPendingApproval,
                            ID = Guid.Parse("7DBA7B39-D23E-493A-9B8F-B94D181A082F")
                        },
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = null,
                            ReferenceDataValue = ReferenceDataValues.AccessLinkStatusDraftPendingReview,
                            ID = Guid.Parse("7B90B2F9-F62F-E711-8735-28D244AEF9ED")
                        }
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.OperationalObjectType,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = ReferenceDataValues.OperationalObjectTypeDP,
                            ReferenceDataValue = ReferenceDataValues.OperationalObjectTypeDP,
                            ID = Guid.Parse("415c9129-0615-457e-98b7-3a60436320c5")
                        }
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.AccessLinkParameters,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = ReferenceDataValues.AccessLinkSameRoadMaxDistance,
                            ReferenceDataValue = "25",
                            ID = Guid.Parse("9DBA7B39-D23E-493A-9B8F-B94D181A082F")
                        },
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = ReferenceDataValues.AccessLinkDiffRoadMaxDistance,
                            ReferenceDataValue = "1",
                            ID = Guid.Parse("3DBA7B39-D23E-493A-9B8F-B94D181A081F")
                        },
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.NetworkLinkType,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = ReferenceDataValues.AccessLinkDiffRoadMaxDistance,
                            ReferenceDataValue = "Road Link",
                            ID = Guid.Parse("09ce57b1-af13-4f8e-b4af-1de35b4a68a8")
                        }
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.AccessLinkParameters,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = "Local Road",
                            ReferenceDataValue = "1",
                            ID = Guid.Parse("4DBA7B35-D23E-493A-9B8F-B94D181A082F")
                        }
                    }
                },
                new ReferenceDataCategoryDTO()
                {
                    CategoryName   = ReferenceDataCategoryNames.DeliveryPointUseIndicator,
                    ReferenceDatas = new List <ReferenceDataDTO>()
                    {
                        new ReferenceDataDTO()
                        {
                            ReferenceDataName  = "DeliveryPointUseIndicator",
                            ReferenceDataValue = "Residential",
                            ID = Guid.Parse("178edcad-9431-e711-83ec-28d244aef9ed")
                        }
                    }
                },
            };

            var networkLinks = new List <NetworkLink>()
            {
                new NetworkLink()
                {
                    ID                  = Guid.Parse("09ce57b1-af13-4f8e-b4af-1de35b4a68a8"),
                    TOID                = "osgb4000000023358315",
                    LinkGeometry        = DbGeometry.LineFromText("LINESTRING (511570.8590967182 106965.35195621933, 511570.8590967182 107474.95297542136, 512474.1409032818 107474.95297542136, 512474.1409032818 106965.35195621933, 511570.8590967182 106965.35195621933)", 27700),
                    NetworkLinkTypeGUID = new Guid("09ce57b1-af13-4f8e-b4af-1de35b4a68a8")
                }
            };

            // Setup for OSRoadLink.
            mockNetworkDBContext = CreateMock <NetworkDBContext>();
            var mockRoadNameDataService = MockDbSet(roadName);

            mockNetworkDBContext.Setup(x => x.Set <OSRoadLink>()).Returns(mockRoadNameDataService.Object);
            mockNetworkDBContext.Setup(x => x.OSRoadLinks).Returns(mockRoadNameDataService.Object);
            mockNetworkDBContext.Setup(c => c.OSRoadLinks.AsNoTracking()).Returns(mockRoadNameDataService.Object);
            mockRoadNameDataService.Setup(x => x.Include(It.IsAny <string>())).Returns(mockRoadNameDataService.Object);

            // Setup for Location.
            var mockRoadNameDataService2 = MockDbSet(location);

            mockNetworkDBContext.Setup(x => x.Set <Location>()).Returns(mockRoadNameDataService2.Object);
            mockNetworkDBContext.Setup(x => x.Locations).Returns(mockRoadNameDataService2.Object);
            mockNetworkDBContext.Setup(c => c.Locations.AsNoTracking()).Returns(mockRoadNameDataService2.Object);
            mockRoadNameDataService2.Setup(x => x.Include(It.IsAny <string>())).Returns(mockRoadNameDataService2.Object);

            // Setup for NetworkLink.
            var mockNetworkLink = MockDbSet(networkLinks);

            mockNetworkDBContext.Setup(x => x.Set <NetworkLink>()).Returns(mockNetworkLink.Object);
            mockNetworkDBContext.Setup(x => x.NetworkLinks).Returns(mockNetworkLink.Object);
            mockNetworkDBContext.Setup(c => c.NetworkLinks.AsNoTracking()).Returns(mockNetworkLink.Object);
            mockNetworkLink.Setup(x => x.Include(It.IsAny <string>())).Returns(mockNetworkLink.Object);

            mockDatabaseFactory = CreateMock <IDatabaseFactory <NetworkDBContext> >();
            mockDatabaseFactory.Setup(x => x.Get()).Returns(mockNetworkDBContext.Object);

            // Setup for IRMTraceManager.
            mockILoggingHelper = CreateMock <ILoggingHelper>();
            var rmTraceManagerMock = new Mock <IRMTraceManager>();

            rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>()));
            mockILoggingHelper.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object);

            testCandidate = new RoadNameDataService(mockDatabaseFactory.Object, mockILoggingHelper.Object);
        }
Exemplo n.º 31
0
 private static double GetRepresentativeXCoordinate(DbGeometry geometry)
 {
     return(geometry.Centroid?.XCoordinate ?? geometry.XCoordinate ?? geometry.Envelope.Centroid.XCoordinate.Value);
 }
 /// <summary>
 /// Constructor for building a new object with MaximalConstructor required fields in preparation for insert into database
 /// </summary>
 public TrashGeneratingUnit4326(int trashGeneratingUnit4326ID, int stormwaterJurisdictionID, int?onlandVisualTrashAssessmentAreaID, int?landUseBlockID, DbGeometry trashGeneratingUnit4326Geometry, DateTime?lastUpdateDate, int?delineationID, int?waterQualityManagementPlanID) : this()
 {
     this.TrashGeneratingUnit4326ID         = trashGeneratingUnit4326ID;
     this.StormwaterJurisdictionID          = stormwaterJurisdictionID;
     this.OnlandVisualTrashAssessmentAreaID = onlandVisualTrashAssessmentAreaID;
     this.LandUseBlockID = landUseBlockID;
     this.TrashGeneratingUnit4326Geometry = trashGeneratingUnit4326Geometry;
     this.LastUpdateDate = lastUpdateDate;
     this.DelineationID  = delineationID;
     this.WaterQualityManagementPlanID = waterQualityManagementPlanID;
 }
        public override bool Contains(DbGeometry geometryValue, DbGeometry otherGeometry)
        {
            if (geometryValue == null)
             throw new ArgumentNullException("geometryValue");

               if (otherGeometry == null)
             throw new ArgumentNullException("otherGeometry");

               DbGeometry mysqlValue = DbGeometry.FromText(geometryValue.ProviderValue.ToString());
               return mysqlValue.Contains(otherGeometry);
        }
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public TrashGeneratingUnit4326(StormwaterJurisdiction stormwaterJurisdiction, DbGeometry trashGeneratingUnit4326Geometry) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.TrashGeneratingUnit4326ID = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.StormwaterJurisdictionID  = stormwaterJurisdiction.StormwaterJurisdictionID;
     this.StormwaterJurisdiction    = stormwaterJurisdiction;
     stormwaterJurisdiction.TrashGeneratingUnit4326s.Add(this);
     this.TrashGeneratingUnit4326Geometry = trashGeneratingUnit4326Geometry;
 }
 public override bool Disjoint(DbGeometry geometryValue, DbGeometry otherGeometry)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 36
0
        protected override void OnSetup()
        {
            SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
            loggingHelperMock = CreateMock <ILoggingHelper>();

            unit1Guid = Guid.NewGuid();
            unit2Guid = Guid.NewGuid();
            unit3Guid = Guid.NewGuid();
            user1Id   = System.Guid.NewGuid();
            user2Id   = System.Guid.NewGuid();
            var unitBoundary = DbGeometry.PolygonFromText("POLYGON ((505058.162109375 100281.69677734375, 518986.84887695312 100281.69677734375, 518986.84887695312 114158.546875, 505058.162109375 114158.546875, 505058.162109375 100281.69677734375))", 27700);

            accessLinkLine = DbGeometry.LineFromText("LINESTRING (488938 197021, 488929.9088937093 197036.37310195228)", 27700);

            var streetNames = new List <StreetName>()
            {
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad1", DesignatedName = "XYZ1", Geometry = unitBoundary
                },
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad2", DesignatedName = "XYZ2", Geometry = unitBoundary
                },
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad3", DesignatedName = "XYZ3", Geometry = unitBoundary
                },
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad4", DesignatedName = "XYZ4", Geometry = unitBoundary
                },
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad5", DesignatedName = "XYZ5", Geometry = unitBoundary
                },
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad6", DesignatedName = "XYZ6", Geometry = unitBoundary
                },
                new StreetName()
                {
                    ID = Guid.NewGuid(), StreetType = "t1", Descriptor = "d1", NationalRoadCode = "Testroad7", DesignatedName = "XYZ7", Geometry = unitBoundary
                }
            };

            var unitLocation = new List <UnitLocation>()
            {
                new UnitLocation()
                {
                    UnitName = "unit1", ExternalId = "extunit1", ID = unit1Guid, UnitBoundryPolygon = unitBoundary, UserRoleUnits = new List <UserRoleUnit> {
                        new UserRoleUnit {
                            Unit_GUID = unit1Guid, User_GUID = user1Id
                        }
                    }
                },
                new UnitLocation()
                {
                    UnitName = "unit2", ExternalId = "extunit2", ID = unit2Guid, UnitBoundryPolygon = unitBoundary, UserRoleUnits = new List <UserRoleUnit> {
                        new UserRoleUnit {
                            Unit_GUID = unit2Guid, User_GUID = user1Id
                        }
                    }
                },
                new UnitLocation()
                {
                    UnitName = "unit3", ExternalId = "extunit2", ID = unit3Guid, UnitBoundryPolygon = unitBoundary, UserRoleUnits = new List <UserRoleUnit> {
                        new UserRoleUnit {
                            Unit_GUID = unit3Guid, User_GUID = user2Id
                        }
                    }
                }
            };

            var networkLink = new List <NetworkLink>()
            {
                new NetworkLink()
                {
                    LinkGeometry = accessLinkLine
                }
            };

            var mockAsynEnumerable           = new DbAsyncEnumerable <StreetName>(streetNames);
            var mockStreetNetworkDataService = MockDbSet(streetNames);

            mockStreetNetworkDataService.As <IQueryable>().Setup(mock => mock.Provider).Returns(mockAsynEnumerable.AsQueryable().Provider);
            mockStreetNetworkDataService.As <IQueryable>().Setup(mock => mock.Expression).Returns(mockAsynEnumerable.AsQueryable().Expression);
            mockStreetNetworkDataService.As <IQueryable>().Setup(mock => mock.ElementType).Returns(mockAsynEnumerable.AsQueryable().ElementType);
            mockStreetNetworkDataService.As <IDbAsyncEnumerable>().Setup(mock => mock.GetAsyncEnumerator()).Returns(((IDbAsyncEnumerable <StreetName>)mockAsynEnumerable).GetAsyncEnumerator());
            mockRMDBContext = CreateMock <RMDBContext>();
            mockRMDBContext.Setup(x => x.Set <StreetName>()).Returns(mockStreetNetworkDataService.Object);
            mockRMDBContext.Setup(x => x.StreetNames).Returns(mockStreetNetworkDataService.Object);

            var mockAsynEnumerable2           = new DbAsyncEnumerable <UnitLocation>(unitLocation);
            var mockStreetNetworkDataService2 = MockDbSet(unitLocation);

            mockStreetNetworkDataService2.As <IQueryable>().Setup(mock => mock.Provider).Returns(mockAsynEnumerable2.AsQueryable().Provider);
            mockStreetNetworkDataService2.As <IQueryable>().Setup(mock => mock.Expression).Returns(mockAsynEnumerable2.AsQueryable().Expression);
            mockStreetNetworkDataService2.As <IQueryable>().Setup(mock => mock.ElementType).Returns(mockAsynEnumerable2.AsQueryable().ElementType);
            mockStreetNetworkDataService2.As <IDbAsyncEnumerable>().Setup(mock => mock.GetAsyncEnumerator()).Returns(((IDbAsyncEnumerable <UnitLocation>)mockAsynEnumerable2).GetAsyncEnumerator());
            mockRMDBContext.Setup(x => x.Set <UnitLocation>()).Returns(mockStreetNetworkDataService2.Object);
            mockRMDBContext.Setup(x => x.UnitLocations).Returns(mockStreetNetworkDataService2.Object);

            var mockAsynEnumerable3 = new DbAsyncEnumerable <NetworkLink>(networkLink);
            var mockNetworkLink     = MockDbSet(networkLink);

            mockNetworkLink.As <IQueryable>().Setup(mock => mock.Provider).Returns(mockAsynEnumerable3.AsQueryable().Provider);
            mockNetworkLink.As <IQueryable>().Setup(mock => mock.Expression).Returns(mockAsynEnumerable3.AsQueryable().Expression);
            mockNetworkLink.As <IQueryable>().Setup(mock => mock.ElementType).Returns(mockAsynEnumerable3.AsQueryable().ElementType);
            mockNetworkLink.As <IDbAsyncEnumerable>().Setup(mock => mock.GetAsyncEnumerator()).Returns(((IDbAsyncEnumerable <NetworkLink>)mockAsynEnumerable3).GetAsyncEnumerator());
            mockRMDBContext.Setup(x => x.Set <NetworkLink>()).Returns(mockNetworkLink.Object);
            mockRMDBContext.Setup(x => x.NetworkLinks).Returns(mockNetworkLink.Object);
            mockRMDBContext.Setup(x => x.NetworkLinks.AsNoTracking()).Returns(mockNetworkLink.Object);

            mockDatabaseFactory = CreateMock <IDatabaseFactory <RMDBContext> >();
            mockDatabaseFactory.Setup(x => x.Get()).Returns(mockRMDBContext.Object);

            var rmTraceManagerMock = new Mock <IRMTraceManager>();

            rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>()));
            loggingHelperMock.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object);

            testCandidate = new StreetNetworkDataService(mockDatabaseFactory.Object, loggingHelperMock.Object);
        }
        public override DbGeometry GetConvexHull(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.ConvexHull;
        }
Exemplo n.º 38
0
        /// <summary>
        /// Setup data
        /// </summary>
        protected override void OnSetup()
        {
            currentUserUnit = "Delivery Office";
            mockDeliveryPointsDataService       = CreateMock <IDeliveryPointsDataService>();
            mockConfigurationDataService        = CreateMock <IConfigurationHelper>();
            mockLoggingDataService              = CreateMock <ILoggingHelper>();
            mockDeliveryPointIntegrationService = CreateMock <IDeliveryPointIntegrationService>();

            var rmTraceManagerMock = new Mock <IRMTraceManager>();

            rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>()));
            mockLoggingDataService.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object);

            SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

            List <DeliveryPointDTO> lstDeliveryPointDTO = new List <DeliveryPointDTO>();
            List <RM.CommonLibrary.EntityFramework.Entities.DeliveryPoint> lstDeliveryPoint = new List <RM.CommonLibrary.EntityFramework.Entities.DeliveryPoint>();
            List <PostalAddressDataDTO> lstPostalAddressDTO = new List <PostalAddressDataDTO>()
            {
                new PostalAddressDataDTO
                {
                    BuildingName   = "Bldg 1",
                    BuildingNumber = 23,
                    Postcode       = "123"
                }
            };

            deliveryPointDTO = new DeliveryPointDTO()
            {
                ID = Guid.NewGuid()
            };

            postalAddressesDTO = new List <PostalAddressDTO>()
            {
                new PostalAddressDTO()
                {
                    BuildingName          = "bldg1",
                    BuildingNumber        = 1,
                    SubBuildingName       = "subbldg",
                    OrganisationName      = "org",
                    DepartmentName        = "department",
                    Thoroughfare          = "ThoroughFare1",
                    DependentThoroughfare = "DependentThoroughFare1",
                    Postcode     = "PostcodeNew",
                    PostTown     = "PostTown",
                    POBoxNumber  = "POBoxNumber",
                    UDPRN        = 12345,
                    PostcodeType = "xyz",
                    SmallUserOrganisationIndicator = "indicator",
                    DeliveryPointSuffix            = "DeliveryPointSuffix",
                    PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                    AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"),
                    ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12")
                },
                new PostalAddressDTO()
                {
                    BuildingName          = "bldg1",
                    BuildingNumber        = 1,
                    SubBuildingName       = "subbldg",
                    OrganisationName      = "org",
                    DepartmentName        = "department",
                    Thoroughfare          = "ThoroughFare1",
                    DependentThoroughfare = "DependentThoroughFare1",
                    Postcode     = "Postcode",
                    PostTown     = "PostTown",
                    POBoxNumber  = "POBoxNumber",
                    UDPRN        = 12345,
                    PostcodeType = "xyz",
                    SmallUserOrganisationIndicator = "indicator",
                    DeliveryPointSuffix            = "DeliveryPointSuffix",
                    PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                    AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"),
                    ID = Guid.Empty
                },
                new PostalAddressDTO()
                {
                    BuildingName          = "bldg1",
                    BuildingNumber        = 1,
                    SubBuildingName       = "subbldg",
                    OrganisationName      = null,
                    DepartmentName        = "department",
                    Thoroughfare          = "ThoroughFare1",
                    DependentThoroughfare = "DependentThoroughFare1",
                    Postcode     = "Postcode",
                    PostTown     = "PostTown",
                    POBoxNumber  = "POBoxNumber",
                    UDPRN        = 12345,
                    PostcodeType = "xyz",
                    SmallUserOrganisationIndicator = "indicator",
                    DeliveryPointSuffix            = "DeliveryPointSuffix",
                    PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                    AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"),
                    ID = Guid.Empty
                }
            };

            addDeliveryPointDTO = new AddDeliveryPointDTO()
            {
                PostalAddressDTO  = postalAddressesDTO[0],
                DeliveryPointDTO  = deliveryPointDTO,
                RangeType         = "Odds",
                DeliveryPointType = "Range",
                FromRange         = 2,
                ToRange           = 11,
            };
            addDeliveryPointDTO1 = new AddDeliveryPointDTO()
            {
                PostalAddressDTO = postalAddressesDTO[1],
                DeliveryPointDTO = deliveryPointDTO
            };

            deliveryPointModelDTO = new DeliveryPointModelDTO()
            {
                ID          = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"),
                XCoordinate = 12,
                YCoordinate = 10,
                UDPRN       = 123,
                Latitude    = 1,
                Longitude   = 2,
                RowVersion  = BitConverter.GetBytes(1)
            };

            actualDeliveryPointDataDto = new List <DeliveryPointDataDTO>()
            {
                new DeliveryPointDataDTO()
                {
                    ID         = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"),
                    MailVolume = 5, PostalAddress = new PostalAddressDataDTO()
                    {
                        BuildingName          = "bldg1",
                        BuildingNumber        = 1,
                        SubBuildingName       = "subbldg",
                        OrganisationName      = "org",
                        DepartmentName        = "department",
                        Thoroughfare          = "ThoroughFare1",
                        DependentThoroughfare = "DependentThoroughFare1",
                        Postcode     = "PostcodeNew",
                        PostTown     = "PostTown",
                        POBoxNumber  = "POBoxNumber",
                        UDPRN        = 12345,
                        PostcodeType = "xyz",
                        SmallUserOrganisationIndicator = "indicator",
                        DeliveryPointSuffix            = "DeliveryPointSuffix",
                        PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                        AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"),
                        ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12")
                    },
                    NetworkNode = new NetworkNodeDataDTO
                    {
                        ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO()
                        {
                            Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700)
                        }
                    },
                    DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>()
                    {
                        new DeliveryPointStatusDataDTO
                        {
                            ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19")
                        }
                    }
                },
                new DeliveryPointDataDTO()
                {
                    ID         = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A17"),
                    MailVolume = 2, PostalAddress = new PostalAddressDataDTO()
                    {
                        BuildingName          = "bldg2",
                        BuildingNumber        = 1,
                        SubBuildingName       = "subbldg1",
                        OrganisationName      = "org",
                        DepartmentName        = "department",
                        Thoroughfare          = "ThoroughFare1",
                        DependentThoroughfare = "DependentThoroughFare1",
                        Postcode     = "PostcodeNew",
                        PostTown     = "PostTown",
                        POBoxNumber  = "POBoxNumber",
                        UDPRN        = 12345,
                        PostcodeType = "xyz",
                        SmallUserOrganisationIndicator = "indicator",
                        DeliveryPointSuffix            = "DeliveryPointSuffix",
                        PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                        AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"),
                        ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19")
                    },
                    NetworkNode = new NetworkNodeDataDTO
                    {
                        ID = Guid.Empty,
                        NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"),
                        Location             = new LocationDataDTO()
                        {
                            Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700)
                        }
                    },
                    DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>()
                    {
                        new DeliveryPointStatusDataDTO
                        {
                            ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19")
                        }
                    }
                }
            };

            actualDeliveryPointDTO = new DeliveryPointDataDTO()
            {
                ID            = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A17"),
                MailVolume    = 2,
                PostalAddress = new PostalAddressDataDTO()
                {
                    BuildingName          = "bldg2",
                    BuildingNumber        = 1,
                    SubBuildingName       = "subbldg1",
                    OrganisationName      = "org",
                    DepartmentName        = "department",
                    Thoroughfare          = "ThoroughFare1",
                    DependentThoroughfare = "DependentThoroughFare1",
                    Postcode     = "PostcodeNew",
                    PostTown     = "PostTown",
                    POBoxNumber  = "POBoxNumber",
                    UDPRN        = 12345,
                    PostcodeType = "xyz",
                    SmallUserOrganisationIndicator = "indicator",
                    DeliveryPointSuffix            = "DeliveryPointSuffix",
                    PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                    AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"),
                    ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19")
                },
                NetworkNode = new NetworkNodeDataDTO {
                    ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO()
                    {
                        Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700)
                    }
                },
                DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>()
                {
                    new DeliveryPointStatusDataDTO {
                        ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19")
                    }
                }
            };

            AddDeliveryPointDTO actualAddDeliveryPointDTO = new AddDeliveryPointDTO()
            {
                PostalAddressDTO = new PostalAddressDTO()
                {
                    BuildingName          = "bldg2",
                    BuildingNumber        = 1,
                    SubBuildingName       = "subbldg1",
                    OrganisationName      = "org",
                    DepartmentName        = "department",
                    Thoroughfare          = "ThoroughFare1",
                    DependentThoroughfare = "DependentThoroughFare1",
                    Postcode     = "PostcodeNew",
                    PostTown     = "PostTown",
                    POBoxNumber  = "POBoxNumber",
                    UDPRN        = 12345,
                    PostcodeType = "xyz",
                    SmallUserOrganisationIndicator = "indicator",
                    DeliveryPointSuffix            = "DeliveryPointSuffix",
                    PostCodeGUID     = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"),
                    AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"),
                    ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19")
                }
            };
            var        locationXy = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700);
            DbGeometry location   = DbGeometry.PointFromText("POINT (488938 197021)", 27700);

            List <RM.CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO> referenceData = GetReferenceDataCategory();
            double xLocation = 399545.5590911182;
            double yLocation = 649744.6394892789;

            routeDTO = new RouteDTO
            {
                RouteName   = "Route-001",
                RouteNumber = "001"
            };

            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoints(It.IsAny <string>(), It.IsAny <Guid>(), It.IsAny <string>())).Returns(actualDeliveryPointDataDto);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO);
            mockDeliveryPointsDataService.Setup(x => x.GetDetailDeliveryPointByUDPRN(It.IsAny <int>())).Returns(actualAddDeliveryPointDTO);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsForBasicSearch(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsCount(It.IsAny <string>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto.Count);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsForAdvanceSearch(It.IsAny <string>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto);

            // GetDeliveryPointsForAdvanceSearch
            mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnUDPRN(It.IsAny <DeliveryPointDataDTO>())).Returns(Task.FromResult(1));

            mockDeliveryPointsDataService.Setup(x => x.UpdatePAFIndicator(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true);

            mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDTO>())).Returns(Task.FromResult("ABC"));
            mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateAddressWithDeliveryPoints(It.IsAny <PostalAddressDTO>())).Returns(Task.FromResult(true));
            mockDeliveryPointIntegrationService.Setup(x => x.CreateAddressForDeliveryPoint(It.IsAny <AddDeliveryPointDTO>())).ReturnsAsync(new CreateDeliveryPointModelDTO()
            {
                ID = Guid.NewGuid(), IsAddressLocationAvailable = true, Message = "Delivery Point Created", XCoordinate = xLocation, YCoordinate = yLocation
            });
            mockDeliveryPointIntegrationService.Setup(x => x.GetReferenceDataSimpleLists(It.IsAny <List <string> >())).ReturnsAsync(referenceData);
            mockDeliveryPointIntegrationService.Setup(x => x.GetApproxLocation(It.IsAny <string>())).ReturnsAsync(location);
            mockDeliveryPointsDataService.Setup(x => x.InsertDeliveryPoint(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(Guid.NewGuid());
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointRowVersion(It.IsAny <Guid>())).Returns(BitConverter.GetBytes(1));
            mockDeliveryPointIntegrationService.Setup(x => x.MapRouteForDeliveryPoint(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true);
            mockDeliveryPointIntegrationService.Setup(x => x.GetReferenceDataGuId(It.IsAny <string>(), It.IsAny <string>())).Returns(Guid.NewGuid());
            mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnID(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(Guid.NewGuid());
            mockDeliveryPointIntegrationService.Setup(x => x.CreateAddressForDeliveryPointForRange(It.IsAny <List <PostalAddressDTO> >())).ReturnsAsync(new List <CreateDeliveryPointModelDTO> {
                new CreateDeliveryPointModelDTO()
                {
                    ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12"), IsAddressLocationAvailable = true, Message = "Delivery Point Created", XCoordinate = xLocation, YCoordinate = yLocation
                }
            });
            mockDeliveryPointIntegrationService.Setup(x => x.GetRouteForDeliveryPoint(It.IsAny <Guid>())).ReturnsAsync(routeDTO);

            mockDeliveryPointsDataService.Setup(x => x.DeliveryPointExists(It.IsAny <int>())).ReturnsAsync(true);

            mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnUDPRN(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(5);

            mockDeliveryPointIntegrationService.Setup(x => x.CreateAccessLink(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(true);
            mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDTO>())).ReturnsAsync("123");
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByUDPRN(It.IsAny <int>())).ReturnsAsync(actualDeliveryPointDTO);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByPostalAddress(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO);

            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsCrossingOperationalObject(It.IsAny <string>(), It.IsAny <DbGeometry>())).Returns(actualDeliveryPointDataDto);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO);
            mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByPostalAddressWithLocation(It.IsAny <Guid>())).ReturnsAsync(actualDeliveryPointDTO);

            testCandidate = new DeliveryPointBusinessService(mockDeliveryPointsDataService.Object, mockLoggingDataService.Object, mockConfigurationDataService.Object, mockDeliveryPointIntegrationService.Object);
        }
        public override int GetDimension(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.Dimension;
        }
        public override double? GetMeasure(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.Measure;
        }
        public override int? GetInteriorRingCount(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.InteriorRingCount;
        }
        public override DbGeometry GetStartPoint(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.StartPoint;
        }
Exemplo n.º 43
0
        public override void Visit(DbConstantExpression e)
        {
            Check.NotNull <DbConstantExpression>(e, nameof(e));
            switch (((PrimitiveType)TypeHelpers.GetPrimitiveTypeUsageForScalar(e.ResultType).EdmType).PrimitiveTypeKind)
            {
            case PrimitiveTypeKind.Binary:
                byte[] numArray = e.Value as byte[];
                if (numArray == null)
                {
                    throw new NotSupportedException();
                }
                this._key.Append("'");
                foreach (int num in numArray)
                {
                    this._key.AppendFormat("{0:X2}", (object)(byte)num);
                }
                this._key.Append("'");
                break;

            case PrimitiveTypeKind.Boolean:
            case PrimitiveTypeKind.Byte:
            case PrimitiveTypeKind.Decimal:
            case PrimitiveTypeKind.Double:
            case PrimitiveTypeKind.Guid:
            case PrimitiveTypeKind.Single:
            case PrimitiveTypeKind.SByte:
            case PrimitiveTypeKind.Int16:
            case PrimitiveTypeKind.Int32:
            case PrimitiveTypeKind.Int64:
            case PrimitiveTypeKind.Time:
                this._key.AppendFormat((IFormatProvider)CultureInfo.InvariantCulture, "{0}", e.Value);
                break;

            case PrimitiveTypeKind.DateTime:
                this._key.Append(((DateTime)e.Value).ToString("o", (IFormatProvider)CultureInfo.InvariantCulture));
                break;

            case PrimitiveTypeKind.String:
                string str = e.Value as string;
                if (str == null)
                {
                    throw new NotSupportedException();
                }
                this._key.Append("'");
                this._key.Append(str.Replace("'", "''"));
                this._key.Append("'");
                break;

            case PrimitiveTypeKind.DateTimeOffset:
                this._key.Append(((DateTimeOffset)e.Value).ToString("o", (IFormatProvider)CultureInfo.InvariantCulture));
                break;

            case PrimitiveTypeKind.Geometry:
            case PrimitiveTypeKind.GeometryPoint:
            case PrimitiveTypeKind.GeometryLineString:
            case PrimitiveTypeKind.GeometryPolygon:
            case PrimitiveTypeKind.GeometryMultiPoint:
            case PrimitiveTypeKind.GeometryMultiLineString:
            case PrimitiveTypeKind.GeometryMultiPolygon:
            case PrimitiveTypeKind.GeometryCollection:
                DbGeometry dbGeometry = e.Value as DbGeometry;
                if (dbGeometry == null)
                {
                    throw new NotSupportedException();
                }
                this._key.Append(dbGeometry.AsText());
                break;

            case PrimitiveTypeKind.Geography:
            case PrimitiveTypeKind.GeographyPoint:
            case PrimitiveTypeKind.GeographyLineString:
            case PrimitiveTypeKind.GeographyPolygon:
            case PrimitiveTypeKind.GeographyMultiPoint:
            case PrimitiveTypeKind.GeographyMultiLineString:
            case PrimitiveTypeKind.GeographyMultiPolygon:
            case PrimitiveTypeKind.GeographyCollection:
                DbGeography dbGeography = e.Value as DbGeography;
                if (dbGeography == null)
                {
                    throw new NotSupportedException();
                }
                this._key.Append(dbGeography.AsText());
                break;

            default:
                throw new NotSupportedException();
            }
            this._key.Append(":");
            this._key.Append(e.ResultType.Identity);
        }
 /// <summary>
 /// When provided in a partial class, allows value of AttrGeometryCollection to be changed before setting.
 /// </summary>
 partial void SetAttrGeometryCollection(DbGeometry oldValue, ref DbGeometry newValue);
        public override string GetSpatialTypeName(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              return mysqlValue.SpatialTypeName;
        }
 public static DbGeometry ToDbGeometry(this IGeometryObject geometryObject)
 {
     return(DbGeometry.FromBinary(WkbEncode.Encode(geometryObject)));
 }
        public override double? GetYCoordinate(DbGeometry geometryValue)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              var providerValue = new MySqlGeometry();
              MySqlGeometry.TryParse(geometryValue.ProviderValue.ToString(), out providerValue);
              return providerValue.YCoordinate;
        }
Exemplo n.º 48
0
            private void Returns_spatial_column_value(PrimitiveTypeKind spatialType, bool useSpatialReader, bool throwException)
            {
                object[][] sourceEnumerable;

                if (spatialType == PrimitiveTypeKind.Geography)
                {
                    sourceEnumerable = new[] { new object[] { DbGeography.FromText("POINT (90 50)") } };
                }
                else
                {
                    sourceEnumerable = new[] { new object[] { DbGeometry.FromText("POINT (90 50)") } };
                }
                var reader = MockHelper.CreateDbDataReader(sourceEnumerable);

                var coordinatorFactory = Objects.MockHelper.CreateCoordinatorFactory(s => s.Reader.GetValue(0));

                var shaperMock = new Mock <Shaper <object> >(
                    reader,
                    /*context*/ null,
                    /*workspace*/ null,
                    MergeOption.AppendOnly,
                    /*stateCount*/ 1,
                    coordinatorFactory,
                    /*readerOwned*/ false,
                    /*streaming*/ useSpatialReader)
                {
                    CallBase = true
                };

                var spatialDataReaderMock = new Mock <DbSpatialDataReader>(MockBehavior.Strict);

                if (useSpatialReader)
                {
                    if (spatialType == PrimitiveTypeKind.Geography)
                    {
                        spatialDataReaderMock.Setup(m => m.GetGeography(0)).Returns((DbGeography)sourceEnumerable.First()[0]);
                    }
                    else
                    {
                        spatialDataReaderMock.Setup(m => m.GetGeometry(0)).Returns((DbGeometry)sourceEnumerable.First()[0]);
                    }
                }
                shaperMock.Protected().Setup <DbSpatialDataReader>("CreateSpatialDataReader").Returns(spatialDataReaderMock.Object);

                reader.Read();

                object result = null;

                if (spatialType == PrimitiveTypeKind.Geography)
                {
                    if (throwException)
                    {
                        Assert.Equal(
                            Strings.Materializer_SetInvalidValue(typeof(DbGeometry), "type", "property", typeof(DbGeography)),
                            Assert.Throws <InvalidOperationException>(
                                () =>
                                shaperMock.Object.GetSpatialPropertyValueWithErrorHandling <DbGeometry>(0, "property", "type", spatialType))
                            .Message);
                    }
                    else
                    {
                        result = shaperMock.Object.GetSpatialPropertyValueWithErrorHandling <DbGeography>(0, "property", "type", spatialType);
                    }
                }
                else
                {
                    if (throwException)
                    {
                        Assert.Equal(
                            Strings.Materializer_SetInvalidValue(typeof(DbGeography), "type", "property", typeof(DbGeometry)),
                            Assert.Throws <InvalidOperationException>(
                                () =>
                                shaperMock.Object.GetSpatialPropertyValueWithErrorHandling <DbGeography>(0, "property", "type", spatialType))
                            .Message);
                    }
                    else
                    {
                        result = shaperMock.Object.GetSpatialPropertyValueWithErrorHandling <DbGeometry>(0, "property", "type", spatialType);
                    }
                }

                if (!throwException)
                {
                    Assert.Equal(sourceEnumerable.First()[0], result);
                }
                if (useSpatialReader)
                {
                    if (spatialType == PrimitiveTypeKind.Geography)
                    {
                        spatialDataReaderMock.Verify(m => m.GetGeography(0), throwException ? Times.Exactly(2) : Times.Once());
                    }
                    else
                    {
                        spatialDataReaderMock.Verify(m => m.GetGeometry(0), throwException ? Times.Exactly(2) : Times.Once());
                    }
                }
            }
 public override string AsGml(DbGeometry geometryValue)
 {
     throw new NotImplementedException();
 }
        private void WorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
        {
            // Shoe ProgressBar
            Dispatcher.BeginInvoke((Action)delegate () {
                _control.LoadingGrid.Visibility = Visibility.Visible;
                _control.statusLabel.Content = "Status: Loading ...";
            });

            if (InputPorts[0] == null || ControlElements[0] == null || InputPorts[0].Data == null) return;

            if (InputPorts[0].Data.GetType() == typeof(DtoShortProject))
            {
                
                var project = InputPorts[0].Data as DtoShortProject;

                if (project != null)
                {
                    projectId = project.Id;
                    var topo = _controller.IntBase.APICore.Projects.GetTopology(project.Id);
                    if (topo == null)
                        return;
                    var model = _controller.IntBase.APICore.DtObjects.GetObjectGeometryAsThreeJs(topo.Id);
                    // var model = _controller.IntBase.APICore.DtObjects.GetObjectGeometry(topo.Id);

                    if (model.Objects == null)
                        return;

                    foreach (var elem in model.Objects)
                    {
                        var geom = new DbGeometry();
                        var jObject = elem.AttributeGroups["geometry"]["threejs"] as JObject;
                        if (jObject != null)
                        {
                            geom.Vertices = jObject.SelectToken("vertices").ToList().Select(value => value.Value<double>()).ToList();
                            geom.Faces = jObject.SelectToken("faces").ToList().Select(value => value.Value<uint>()).ToList();

                            var colorid = (int)jObject.SelectToken("metadata")["colorid"];
                            var colorInteger = model.Colors[colorid];
                            var color = Color.FromArgb((int)colorInteger);

                            GeometryWriter.EvaluateAndSaveGeometry(geom, elem, color);
                        }
                    }
                    
                    // model.Colors
                    // Color c = Color.FromArgb(someInt);

                    // var model = _controller.IntBase.APICore.DtObjects.GetObjectGeometry(topo.Id);
                    _elements = (List<DtObject>) model.Objects;
                }
                // _elements = _controller.IntBase.APICore.GetElementsFromTopologyId(project.Id);
                // OutputPorts[0].Data = _elements;
            }

            if (InputPorts[0].Data.GetType() == typeof(DtoDivision))
            {
                var dtoDivision = InputPorts[0].Data as DtoDivision;
                if (dtoDivision?.TopologyDivisionId != null)
                {
                    var model = _controller.IntBase.APICore.DtObjects.GetObjectGeometryAsThreeJs((Guid)dtoDivision.TopologyDivisionId);
                    projectId = dtoDivision.ProjectId;

                    foreach (var elem in model.Objects)
                    {
                        var geom = new DbGeometry();
                        var jObject = elem.AttributeGroups["geometry"]["threejs"] as JObject;
                        if (jObject != null)
                        {
                            geom.Vertices = jObject.SelectToken("vertices").ToList().Select(value => value.Value<double>()).ToList();
                            geom.Faces = jObject.SelectToken("faces").ToList().Select(value => value.Value<uint>()).ToList();

                            var colorid = (int)jObject.SelectToken("metadata")["colorid"];
                            var colorInteger = model.Colors[colorid];
                            var color = Color.FromArgb((int)colorInteger);

                            GeometryWriter.EvaluateAndSaveGeometry(geom, elem, color);
                        }
                    }
                    _elements = (List<DtObject>)model.Objects;
                }
            }

            doWorkEventArgs.Result = _elements;
        }
        public override bool Relate(DbGeometry geometryValue, DbGeometry otherGeometry, string matrix)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              if (otherGeometry == null)
            throw new ArgumentNullException("otherGeometry");

              if (String.IsNullOrEmpty(matrix))
            throw new ArgumentNullException("matrix");

              var mysqlValue = GeometryFromProviderValue(geometryValue);

              var mysqlOtherValue = GeometryFromProviderValue(otherGeometry);

              return mysqlValue.Relate(mysqlOtherValue, matrix);
        }
Exemplo n.º 52
0
        //returns geoJSON from geometry
        public string GetGeoJsonFromGeometry(DbGeometry dBGeometry)
        {
            var geoJsonWriter = new GeoJsonWriter();

            return(geoJsonWriter.Write(dBGeometry));
        }
        public override bool Within(DbGeometry geometryValue, DbGeometry otherGeometry)
        {
            if (geometryValue == null)
            throw new ArgumentNullException("geometryValue");

              if (otherGeometry == null)
            throw new ArgumentNullException("otherGeometry");

              var mysqlValue = GeometryFromProviderValue(geometryValue);
              var mysqlOtherValue = GeometryFromProviderValue(otherGeometry);
              return  mysqlValue.Within(mysqlOtherValue);
        }
Exemplo n.º 54
0
 /// <summary>
 /// Generates SQL to specify a constant geometry default value being set on a column.
 /// This method just generates the actual value, not the SQL to set the default value.
 /// </summary>
 /// <param name="defaultValue"> The value to be set. </param>
 /// <returns> SQL representing the default value. </returns>
 protected virtual string Generate(DbGeometry defaultValue)
 {
     return("'" + defaultValue + "'");
 }