public void CanGetGeometryToStoreForZeroLengthLine()
        {
            IPolyline polyline = GeometryFactory.CreatePolyline(0, 10, 100,
                                                                0, 10, 100,
                                                                dontSimplify: true);

            polyline.SpatialReference = CreateSpatialReference();

            IGeometry result = ErrorRepositoryUtils.GetGeometryToStore(polyline,
                                                                       polyline
                                                                       .SpatialReference,
                                                                       _storedGeometryTypes);

            Console.WriteLine(GeometryUtils.ToString(result));

            var multipoint = result as IMultipoint;

            Assert.NotNull(multipoint);
            Assert.AreEqual(1, ((IPointCollection)multipoint).PointCount);
            IPoint point = ((IPointCollection)multipoint).Point[0];

            Assert.AreEqual(0, point.X);
            Assert.AreEqual(10, point.Y);
            Assert.AreEqual(100, point.Z);
            Assert.AreEqual(polyline.SpatialReference, point.SpatialReference);
        }
        public void CanGetGeometryToStoreForZeroAreaCollapsedPolygon()
        {
            IPolygon polygon = GeometryFactory.CreatePolygon(CreateSpatialReference());

            ((ISegmentCollection)polygon).SetRectangle(
                GeometryFactory.CreateEnvelope(0, 10, 0, 10, polygon.SpatialReference));

            GeometryUtils.MakeZAware(polygon);
            GeometryUtils.ApplyConstantZ(polygon, 100);

            IGeometry result = ErrorRepositoryUtils.GetGeometryToStore(polygon,
                                                                       polygon.SpatialReference,
                                                                       _storedGeometryTypes);

            Console.WriteLine(GeometryUtils.ToString(result));

            var multipoint = result as IMultipoint;

            Assert.NotNull(multipoint);
            Assert.AreEqual(1, ((IPointCollection)multipoint).PointCount);
            IPoint point = ((IPointCollection)multipoint).Point[0];

            Assert.AreEqual(0, point.X);
            Assert.AreEqual(10, point.Y);
            Assert.AreEqual(100, point.Z);
            Assert.AreEqual(polygon.SpatialReference, point.SpatialReference);
        }
Exemplo n.º 3
0
        private IGeometry GetStorableIssueGeometry([CanBeNull] IGeometry issueGeometry)
        {
            if (_spatialReference == null)
            {
                return(null);
            }

            return(ErrorRepositoryUtils.GetGeometryToStore(issueGeometry,
                                                           _spatialReference,
                                                           _issueWritersByGeometryType
                                                           .Keys));
        }
        public void CanGetGeometryToStoreForRegularPolygon()
        {
            IPolygon polygon = GeometryFactory.CreatePolygon(0, 0, 10, 10,
                                                             CreateSpatialReference());

            GeometryUtils.MakeZAware(polygon);
            GeometryUtils.ApplyConstantZ(polygon, 100);

            IGeometry result = ErrorRepositoryUtils.GetGeometryToStore(polygon,
                                                                       polygon.SpatialReference,
                                                                       _storedGeometryTypes);

            Assert.IsTrue(GeometryUtils.AreEqual(polygon, result));
        }
        public void CanGetGeometryToStoreForRegularLine()
        {
            IPolyline polyline = GeometryFactory.CreatePolyline(0, 10, 100,
                                                                5, 10, 100,
                                                                dontSimplify: true);

            polyline.SpatialReference = CreateSpatialReference();

            IGeometry result = ErrorRepositoryUtils.GetGeometryToStore(
                polyline,
                polyline.SpatialReference,
                _storedGeometryTypes);

            Assert.IsTrue(GeometryUtils.AreEqual(polyline, result));
        }
        public void CanGetGeometryToStoreForZeroAreaLinearPolygon()
        {
            IPolygon polygon = GeometryFactory.CreatePolygon(CreateSpatialReference());

            ((ISegmentCollection)polygon).SetRectangle(
                GeometryFactory.CreateEnvelope(0, 0, 10, 0, polygon.SpatialReference));

            GeometryUtils.MakeZAware(polygon);
            GeometryUtils.ApplyConstantZ(polygon, 100);

            IGeometry result = ErrorRepositoryUtils.GetGeometryToStore(polygon,
                                                                       polygon.SpatialReference,
                                                                       _storedGeometryTypes);

            Console.WriteLine(GeometryUtils.ToString(result));

            IPolyline expectedPolyline = GeometryFactory.CreatePolyline(0, 0, 10, 0);

            GeometryUtils.MakeZAware(expectedPolyline);
            GeometryUtils.ApplyConstantZ(expectedPolyline, 100);
            expectedPolyline.SpatialReference = polygon.SpatialReference;

            Assert.IsTrue(GeometryUtils.AreEqual(expectedPolyline, result));
        }
Exemplo n.º 7
0
        public static QaError GetForAllowedErrorComparison(
            [NotNull] QaError qaError,
            [NotNull] ISpatialReference spatialReference,
            [NotNull] ICollection <esriGeometryType> storedGeometryTypes,
            bool forPre10Geodatabase)
        {
            Assert.ArgumentNotNull(qaError, nameof(qaError));
            Assert.ArgumentNotNull(spatialReference, nameof(spatialReference));

            if (qaError.Geometry == null)
            {
                return(qaError);
            }

            return(new QaError(qaError.Test,
                               qaError.Description,
                               qaError.InvolvedRows,
                               ErrorRepositoryUtils.GetGeometryToStore(qaError.Geometry,
                                                                       spatialReference,
                                                                       storedGeometryTypes,
                                                                       forPre10Geodatabase),
                               qaError.IssueCode,
                               qaError.AffectedComponent));
        }
Exemplo n.º 8
0
        private static IssueMsg CreateIssueProto(
            [NotNull] IssueFoundEventArgs args,
            [NotNull] IBackgroundVerificationInputs backgroundVerificationInputs)
        {
            QualityCondition qualityCondition =
                args.QualitySpecificationElement.QualityCondition;

            IssueMsg issueProto = new IssueMsg();

            issueProto.ConditionId   = qualityCondition.Id;
            issueProto.Allowable     = args.IsAllowable;
            issueProto.StopCondition = args.Issue.StopCondition;

            CallbackUtils.DoWithNonNull(
                args.Issue.Description, s => issueProto.Description = s);

            IssueCode issueCode = args.Issue.IssueCode;

            if (issueCode != null)
            {
                CallbackUtils.DoWithNonNull(
                    issueCode.ID, s => issueProto.IssueCodeId = s);

                CallbackUtils.DoWithNonNull(
                    issueCode.Description, s => issueProto.IssueCodeDescription = s);
            }

            CallbackUtils.DoWithNonNull(
                args.Issue.AffectedComponent,
                (value) => issueProto.AffectedComponent = value);

            issueProto.InvolvedTables.AddRange(GetInvolvedTableMessages(args.Issue.InvolvedTables));

            CallbackUtils.DoWithNonNull(
                args.LegacyInvolvedObjectsString,
                (value) => issueProto.LegacyInvolvedRows = value);

            IVerificationContext verificationContext =
                Assert.NotNull(backgroundVerificationInputs.VerificationContext);

            var supportedGeometryTypes =
                GetSupportedErrorRepoGeometryTypes(verificationContext).ToList();

            // create valid Error geometry (geometry type, min dimensions) if possible
            IGeometry geometry = ErrorRepositoryUtils.GetGeometryToStore(
                args.ErrorGeometry,
                verificationContext.SpatialReferenceDescriptor.SpatialReference,
                supportedGeometryTypes);

            issueProto.IssueGeometry =
                ProtobufGeometryUtils.ToShapeMsg(geometry);

            // NOTE: Multipatches are not restored from byte arrays in EsriShape (10.6.1)
            ShapeMsg.FormatOneofCase format =
                geometry?.GeometryType == esriGeometryType.esriGeometryMultiPatch
                                        ? ShapeMsg.FormatOneofCase.Wkb
                                        : ShapeMsg.FormatOneofCase.EsriShape;

            issueProto.IssueGeometry =
                ProtobufGeometryUtils.ToShapeMsg(geometry, format);

            issueProto.CreationDateTimeTicks = DateTime.Now.Ticks;

            //issueProto.IsInvalidException = args.us;

            //if (args.IsAllowed)
            //{
            //	issueProto.ExceptedObjRef = new GdbObjRefMsg()
            //	                            {
            //		                            ClassHandle = args.AllowedErrorRef.ClassId,
            //		                            ObjectId = args.AllowedErrorRef.ObjectId
            //	                            };
            //}

            return(issueProto);
        }