public void Add(SpaceFillingCurve sFC) { for (int i = 0; i < sFC.NumberOfSteps - 1; i++) { this.Add(sFC[i]); } }
private void StartSeekForRange(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, IndexQuery.GeometryRangePredicate rangePredicate, IndexQuery[] query) { try { BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, descriptor.schema().PropertyIds); client.Initialize(descriptor, multiProgressor, query, IndexOrder.NONE, false); SpaceFillingCurve curve = _spatial.SpaceFillingCurve; double[] from = rangePredicate.From() == null ? null : rangePredicate.From().coordinate(); double[] to = rangePredicate.To() == null ? null : rangePredicate.To().coordinate(); IList <SpaceFillingCurve.LongRange> ranges = curve.GetTilesIntersectingEnvelope(from, to, _configuration); foreach (SpaceFillingCurve.LongRange range in ranges) { SpatialIndexKey treeKeyFrom = layout.newKey(); SpatialIndexKey treeKeyTo = layout.newKey(); InitializeKeys(treeKeyFrom, treeKeyTo); treeKeyFrom.FromDerivedValue(long.MinValue, range.Min); treeKeyTo.FromDerivedValue(long.MaxValue, range.Max + 1); RawCursor <Hit <SpatialIndexKey, VALUE>, IOException> seeker = makeIndexSeeker(treeKeyFrom, treeKeyTo, IndexOrder.NONE); IndexProgressor hitProgressor = new NativeHitIndexProgressor <>(seeker, client, openSeekers); multiProgressor.Initialize(descriptor, hitProgressor, query, IndexOrder.NONE, false); } } catch (System.ArgumentException) { // Invalid query ranges will cause this state (eg. min>max) client.Initialize(descriptor, IndexProgressor.EMPTY, query, IndexOrder.NONE, false); } catch (IOException e) { throw new UncheckedIOException(e); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void comparePointsMustOnlyReturnZeroForEqualPoints() internal virtual void ComparePointsMustOnlyReturnZeroForEqualPoints() { PointValue firstPoint = _random.randomValues().nextPointValue(); PointValue equalPoint = Values.point(firstPoint); CoordinateReferenceSystem crs = firstPoint.CoordinateReferenceSystem; SpaceFillingCurve curve = _noSpecificIndexSettings.forCrs(crs, false); long? spaceFillingCurveValue = curve.DerivedValueFor(firstPoint.Coordinate()); PointValue centerPoint = Values.pointValue(crs, curve.CenterPointFor(spaceFillingCurveValue.Value)); GenericKey firstKey = NewKeyState(); firstKey.WriteValue(firstPoint, NEUTRAL); GenericKey equalKey = NewKeyState(); equalKey.WriteValue(equalPoint, NEUTRAL); GenericKey centerKey = NewKeyState(); centerKey.WriteValue(centerPoint, NEUTRAL); GenericKey noCoordsKey = NewKeyState(); noCoordsKey.WriteValue(equalPoint, NEUTRAL); GeometryType.NoCoordinates = noCoordsKey; assertEquals(0, firstKey.CompareValueTo(equalKey), "expected keys to be equal"); assertEquals(firstPoint.CompareTo(centerPoint) != 0, firstKey.CompareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal"); assertEquals(0, firstKey.CompareValueTo(noCoordsKey), "expected keys to be equal"); }
private void UpdateCurve(int tableId, int code) { if (this.Long1 != tableId || this.Long2 != code) { Long1 = tableId; Long2 = code; SpaceFillingCurve = _settings.forCrs(tableId, code, true); } }
/* <initializers> */ internal virtual void Clear() { if (TypeConflict == Types.Text && booleanOf(Long1)) { // Clear byteArray if it has been dereferenced ByteArray = null; } TypeConflict = null; Long0 = 0; Long1 = 0; Long2 = 0; Long3 = 0; Inclusion = NEUTRAL; IsArray = false; ArrayLength = 0; IsHighestArray = false; CurrentArrayOffset = 0; SpaceFillingCurve = null; }
private IEnumerable <Vector2> EvaluateHilbert(int order, bool normalized = true) { var points = new List <Vector2>(); uint x = 0, y = 1; ulong i = 1; uint max = 0; while (x != 0 || y != 0) { SpaceFillingCurve.ReverseHilbert(order, i, out x, out y); points.Add(new Vector2(x, y)); if (x > max) { max = x; } i++; } return(normalized ? points.Select(p => p / (max + 1)) : points); }
public override void Query(Org.Neo4j.Storageengine.Api.schema.IndexProgressor_NodeValueClient client, IndexOrder indexOrder, bool needsValues, params IndexQuery[] query) { IndexQuery.GeometryRangePredicate geometryRangePredicate = GetGeometryRangePredicateIfAny(query); if (geometryRangePredicate != null) { ValidateQuery(indexOrder, query); try { // If there's a GeometryRangeQuery among the predicates then this query changes from a straight-forward: build from/to and seek... // into a query that is split into multiple sub-queries. Predicates both before and after will have to be accompanied each sub-query. BridgingIndexProgressor multiProgressor = new BridgingIndexProgressor(client, Descriptor.schema().PropertyIds); client.Initialize(Descriptor, multiProgressor, query, indexOrder, needsValues); double[] from = geometryRangePredicate.From() == null ? null : geometryRangePredicate.From().coordinate(); double[] to = geometryRangePredicate.To() == null ? null : geometryRangePredicate.To().coordinate(); CoordinateReferenceSystem crs = geometryRangePredicate.Crs(); SpaceFillingCurve curve = _spaceFillingCurveSettings.forCrs(crs, false); IList <SpaceFillingCurve.LongRange> ranges = curve.GetTilesIntersectingEnvelope(from, to, _configuration); foreach (SpaceFillingCurve.LongRange range in ranges) { // Here's a sub-query that we'll have to do for this geometry range. Build this query from all predicates // and when getting to the geometry range predicate that sparked these sub-query chenanigans, swap in this sub-query in its place. GenericKey treeKeyFrom = Layout.newKey(); GenericKey treeKeyTo = Layout.newKey(); InitializeFromToKeys(treeKeyFrom, treeKeyTo); bool needFiltering = InitializeRangeForGeometrySubQuery(treeKeyFrom, treeKeyTo, query, crs, range); StartSeekForInitializedRange(multiProgressor, treeKeyFrom, treeKeyTo, query, indexOrder, needFiltering, needsValues); } } catch (System.ArgumentException) { // Invalid query ranges will cause this state (eg. min>max) client.Initialize(Descriptor, IndexProgressor.EMPTY, query, indexOrder, needsValues); } } else { base.Query(client, indexOrder, needsValues, query); } }
public static RegionMoves Measure(SpaceFillingCurve sFC, int level, firstToOtherSubregionTransforms firstToOtherSubregions) { RegionMoves totalRegionMoves = new RegionMoves(); RegionMoves regionMoves = new RegionMoves(); if (level == 0) { regionMoves.Add(sFC); return(regionMoves); } else { regionMoves = Measure(sFC.CalculateSubregionBMFs(0), level - 1, firstToOtherSubregions); totalRegionMoves = RegionMoves.Combine(regionMoves, totalRegionMoves); List <Transform> transforms = firstToOtherSubregions(sFC.CalculateSubregionBMFs(0).GetMoves()); int subRegionSize = (int)Math.Pow(sFC.BaseSize, level); for (int i = 0; i < sFC.NumberOfSteps - 1; i++) { RegionMoves otherRegionMoves = regionMoves.Transform(transforms[i]); totalRegionMoves = RegionMoves.Combine(otherRegionMoves, totalRegionMoves); Point tempPoint01 = sFC.CalculateSubregionBMFs(i).TraverseTheBasePath(new Point(0, 0), subRegionSize - 1).Last(); Point tempPoint02 = sFC.MoveToNextRegion(i, new Point(0, 0), subRegionSize); totalRegionMoves.Add(new Move((p, s) => new Point(p.X + tempPoint02.X - tempPoint01.X, p.Y + tempPoint02.Y - tempPoint01.Y))); } return(totalRegionMoves); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void comparePointArraysMustOnlyReturnZeroForEqualArrays() internal virtual void ComparePointArraysMustOnlyReturnZeroForEqualArrays() { PointArray firstArray = _random.randomValues().nextPointArray(); PointValue[] sourcePointValues = firstArray.AsObjectCopy(); PointArray equalArray = Values.pointArray(sourcePointValues); PointValue[] centerPointValues = new PointValue[sourcePointValues.Length]; for (int i = 0; i < sourcePointValues.Length; i++) { PointValue sourcePointValue = sourcePointValues[i]; CoordinateReferenceSystem crs = sourcePointValue.CoordinateReferenceSystem; SpaceFillingCurve curve = _noSpecificIndexSettings.forCrs(crs, false); long?spaceFillingCurveValue = curve.DerivedValueFor(sourcePointValue.Coordinate()); centerPointValues[i] = Values.pointValue(crs, curve.CenterPointFor(spaceFillingCurveValue.Value)); } PointArray centerArray = Values.pointArray(centerPointValues); GenericKey firstKey = NewKeyState(); firstKey.WriteValue(firstArray, NEUTRAL); GenericKey equalKey = NewKeyState(); equalKey.WriteValue(equalArray, NEUTRAL); GenericKey centerKey = NewKeyState(); centerKey.WriteValue(centerArray, NEUTRAL); GenericKey noCoordsKey = NewKeyState(); noCoordsKey.WriteValue(equalArray, NEUTRAL); GeometryType.NoCoordinates = noCoordsKey; assertEquals(0, firstKey.CompareValueTo(equalKey), "expected keys to be equal"); assertEquals(firstArray.compareToSequence(centerArray, AnyValues.COMPARATOR) != 0, firstKey.CompareValueTo(centerKey) != 0, "expected keys to be equal if and only if source points are equal"); assertEquals(0, firstKey.CompareValueTo(noCoordsKey), "expected keys to be equal"); }