Пример #1
0
        /// <summary>
        /// Select the part corresponding to the given CoordinateReferenceSystem. Creates the part if needed,
        /// and rethrows any create time exception as a RuntimeException.
        /// </summary>
        /// <param name="crs"> target coordinate reference system </param>
        /// <returns> selected part </returns>
        internal virtual T UncheckedSelect(CoordinateReferenceSystem crs)
        {
            T existing = Cache[crs];

            if (existing != default(T))
            {
                return(existing);
            }

            // Instantiate from factory. Do this under lock so that we coordinate with any concurrent call to close.
            // Concurrent calls to instantiating parts won't contend with each other since there's only
            // a single writer at a time anyway.
            InstantiateCloseLock.@lock();
            try
            {
                AssertOpen();
                return(Cache.computeIfAbsent(crs, key =>
                {
                    try
                    {
                        return _factory.newSpatial(crs);
                    }
                    catch (IOException e)
                    {
                        throw new UncheckedIOException(e);
                    }
                }));
            }
            finally
            {
                InstantiateCloseLock.unlock();
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public static <VALUE extends org.neo4j.values.storable.Value> RangePredicate<?> range(int propertyKeyId, VALUE from, boolean fromInclusive, VALUE to, boolean toInclusive)
        public static RangePredicate <object> Range <VALUE>(int propertyKeyId, VALUE from, bool fromInclusive, VALUE to, bool toInclusive) where VALUE : Org.Neo4j.Values.Storable.Value
        {
            if (from == null && to == null)
            {
                throw new System.ArgumentException("Cannot create RangePredicate without at least one bound");
            }

            ValueGroup valueGroup = from != null?from.valueGroup() : to.valueGroup();

            switch (valueGroup.innerEnumValue)
            {
            case ValueGroup.InnerEnum.NUMBER:
                return(new NumberRangePredicate(propertyKeyId, ( NumberValue )from, fromInclusive, ( NumberValue )to, toInclusive));

            case ValueGroup.InnerEnum.TEXT:
                return(new TextRangePredicate(propertyKeyId, ( TextValue )from, fromInclusive, ( TextValue )to, toInclusive));

            case ValueGroup.InnerEnum.GEOMETRY:
                PointValue pFrom = ( PointValue )from;
                PointValue pTo   = ( PointValue )to;
                CoordinateReferenceSystem crs = pFrom != null ? pFrom.CoordinateReferenceSystem : pTo.CoordinateReferenceSystem;
                return(new GeometryRangePredicate(propertyKeyId, crs, pFrom, fromInclusive, pTo, toInclusive));

            default:
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: return new RangePredicate<>(propertyKeyId, valueGroup, from, fromInclusive, to, toInclusive);
                return(new RangePredicate <object>(propertyKeyId, valueGroup, from, fromInclusive, to, toInclusive));
            }
        }
Пример #3
0
 internal virtual void LoadAll()
 {
     foreach (CoordinateReferenceSystem crs in CoordinateReferenceSystem.all())
     {
         UncheckedSelect(crs);
     }
 }
Пример #4
0
        /// <summary>
        /// Select the part corresponding to the given CoordinateReferenceSystem, apply function to it and return the result.
        /// If the part isn't created yet return orElse.
        /// </summary>
        /// <param name="crs"> target coordinate reference system </param>
        /// <param name="function"> function to apply to part </param>
        /// <param name="orElse"> result to return if part isn't created yet </param>
        /// @param <RESULT> type of result </param>
        /// <returns> the result </returns>
        internal virtual RESULT SelectOrElse <RESULT>(CoordinateReferenceSystem crs, System.Func <T, RESULT> function, RESULT orElse)
        {
            T part = Cache[crs];

            if (part == default(T))
            {
                return(orElse);
            }
            return(function(part));
        }
Пример #5
0
 public void visit(CoordinateReferenceSystem crs, SpaceFillingCurveSettings settings)
 {
     // For tableId+code the native layout is even stricter here, but it'd add unnecessary complexity to shave off a couple of more bits
     _cursor.putByte(( sbyte )assertInt("table id", crs.Table.TableId, 0xFF));
     _cursor.putInt(crs.Code);
     _cursor.putShort(( short )assertInt("max levels", settings.MaxLevelsConflict, 0xFFFF));
     _cursor.putShort(( short )assertInt("dimensions", settings.DimensionsConflict, 0xFFFF));
     double[] min = settings.Extents.Min;
     double[] max = settings.Extents.Max;
     for (int i = 0; i < settings.DimensionsConflict; i++)
     {
         _cursor.putLong(System.BitConverter.DoubleToInt64Bits(min[i]));
         _cursor.putLong(System.BitConverter.DoubleToInt64Bits(max[i]));
     }
 }
Пример #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static void testPoint(String query, double[] expectedCoordinate, org.neo4j.values.storable.CoordinateReferenceSystem expectedCrs, String expectedType) throws Exception
        private static void TestPoint(string query, double[] expectedCoordinate, CoordinateReferenceSystem expectedCrs, string expectedType)
        {
            HTTP.Response response = RunQuery(query);

            assertEquals(200, response.Status());
            AssertNoErrors(response);

            JsonNode element = ExtractSingleElement(response);

            AssertGeometryTypeEqual(GeometryType.GEOMETRY_POINT, element);
            AssertCoordinatesEqual(expectedCoordinate, element);
            AssertCrsEqual(expectedCrs, element);

            AssertTypeEqual(expectedType, response);
        }
Пример #7
0
 internal SpatialLayout(CoordinateReferenceSystem crs, SpaceFillingCurve curve) : base("UPI", 0, 1)
 {
     this.Crs    = crs;
     this._curve = curve;
 }
Пример #8
0
 /// <summary>
 /// Extracts raw bits from a <seealso cref="PointValue"/> and store as state of this <seealso cref="SpatialIndexKey"/> instance.
 /// </summary>
 public override void WritePoint(CoordinateReferenceSystem crs, double[] coordinate)
 {
     RawValueBits = Curve.derivedValueFor(coordinate).Value;
 }
Пример #9
0
 internal SpatialIndexKey(CoordinateReferenceSystem crs, SpaceFillingCurve curve)
 {
     this.Crs   = crs;
     this.Curve = curve;
 }
Пример #10
0
 internal GeometryRangePredicate(int propertyKeyId, CoordinateReferenceSystem crs, PointValue from, bool fromInclusive, PointValue to, bool toInclusive) : base(propertyKeyId, ValueGroup.GEOMETRY, from, fromInclusive, to, toInclusive)
 {
     this.CrsConflict = crs;
 }
Пример #11
0
        /// <summary>
        /// Create IndexQuery for retrieving all indexed entries with spatial value of the given
        /// coordinate reference system.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public static RangePredicate<?> range(int propertyKeyId, org.neo4j.values.storable.CoordinateReferenceSystem crs)
        public static RangePredicate <object> Range(int propertyKeyId, CoordinateReferenceSystem crs)
        {
            return(new GeometryRangePredicate(propertyKeyId, crs, null, true, null, true));
        }
Пример #12
0
 public override IndexUpdater NewSpatial(CoordinateReferenceSystem crs)
 {
     return(Populator.select(crs).newPopulatingUpdater(NodePropertyAccessor));
 }
Пример #13
0
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: public NativeIndexUpdater<?,NativeIndexValue> newSpatial(org.neo4j.values.storable.CoordinateReferenceSystem crs)
            public override NativeIndexUpdater <object, NativeIndexValue> NewSpatial(CoordinateReferenceSystem crs)
            {
                return(Accessor.select(crs).newUpdater(Mode));
            }
Пример #14
0
 private static void AssertCrsEqual(CoordinateReferenceSystem crs, JsonNode element)
 {
     assertEquals(crs.Name, element.get("crs").get("name").asText());
 }
Пример #15
0
 /// <summary>
 /// Select the part corresponding to the given CoordinateReferenceSystem. Creates the part if needed,
 /// in which case an exception of type E might be thrown.
 /// </summary>
 /// <param name="crs"> target coordinate reference system </param>
 /// <returns> selected part </returns>
 internal virtual T Select(CoordinateReferenceSystem crs)
 {
     return(UncheckedSelect(crs));
 }