Exemplo n.º 1
0
 public override void WritePoint(CoordinateReferenceSystem crs, double[] coordinate)
 {
     if (!IsArray)
     {
         Type = Types.Geometry;
         UpdateCurve(crs.Table.TableId, crs.Code);
         Types.Geometry.write(this, SpaceFillingCurve.derivedValueFor(coordinate).Value, coordinate);
     }
     else
     {
         if (CurrentArrayOffset == 0)
         {
             UpdateCurve(crs.Table.TableId, crs.Code);
         }
         else if (this.Long1 != crs.Table.TableId || this.Long2 != crs.Code)
         {
             throw new System.InvalidOperationException(format("Tried to assign a geometry array containing different coordinate reference systems, first:%s, violating:%s at array position:%d", CoordinateReferenceSystem.get(( int )Long1, ( int )Long2), crs, CurrentArrayOffset));
         }
         Types.GeometryArray.write(this, CurrentArrayOffset++, SpaceFillingCurve.derivedValueFor(coordinate).Value, coordinate);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// This test verify that we correctly handle unique points that all belong to the same tile on the space filling curve.
        /// All points share at least one dimension coordinate with another point to exercise minimal splitter.
        /// We verify this by asserting that we always get exactly one hit on an exact match and that the value is what we expect.
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustHandlePointsWithinSameTile() throws org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException, org.neo4j.internal.kernel.api.exceptions.schema.IndexNotApplicableKernelException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustHandlePointsWithinSameTile()
        {
            // given
            // Many random points that all are close enough to each other to belong to the same tile on the space filling curve.
            int        nbrOfValues = 10000;
            PointValue origin      = Values.pointValue(WGS84, 0.0, 0.0);
            long?      derivedValueForCenterPoint = _curve.derivedValueFor(origin.Coordinate());

            double[] centerPoint      = _curve.centerPointFor(derivedValueForCenterPoint.Value);
            double   xWidthMultiplier = _curve.getTileWidth(0, _curve.MaxLevel) / 2;
            double   yWidthMultiplier = _curve.getTileWidth(1, _curve.MaxLevel) / 2;

            IList <Value> pointValues = new List <Value>();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.List<org.neo4j.kernel.api.index.IndexEntryUpdate<?>> updates = new java.util.ArrayList<>();
            IList <IndexEntryUpdate <object> > updates = new List <IndexEntryUpdate <object> >();
            long nodeId = 1;

            for (int i = 0; i < nbrOfValues / 4; i++)
            {
                double     x1      = (_random.NextDouble() * 2 - 1) * xWidthMultiplier;
                double     x2      = (_random.NextDouble() * 2 - 1) * xWidthMultiplier;
                double     y1      = (_random.NextDouble() * 2 - 1) * yWidthMultiplier;
                double     y2      = (_random.NextDouble() * 2 - 1) * yWidthMultiplier;
                PointValue value11 = Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y1);
                PointValue value12 = Values.pointValue(WGS84, centerPoint[0] + x1, centerPoint[1] + y2);
                PointValue value21 = Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y1);
                PointValue value22 = Values.pointValue(WGS84, centerPoint[0] + x2, centerPoint[1] + y2);
                AssertDerivedValue(derivedValueForCenterPoint, value11, value12, value21, value22);

                nodeId = AddPointsToLists(pointValues, updates, nodeId, value11, value12, value21, value22);
            }

            ProcessAll(updates);

            // then
            ExactMatchOnAllValues(pointValues);
        }