示例#1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pointArraysOfWgs84()
        public virtual void PointArraysOfWgs84()
        {
            PointValue[] array = new PointValue[] { Values.pointValue(CoordinateReferenceSystem.WGS84, -45.0, -45.0), Values.pointValue(CoordinateReferenceSystem.WGS84, 12.8, 56.3) };
            int          numberOfBitsUsedForDoubles = 64;

            AssertPointArrayHasCorrectFormat(array, numberOfBitsUsedForDoubles);
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void failToCreatePointArrayOnOldDatabase()
        internal virtual void FailToCreatePointArrayOnOldDatabase()
        {
            File storeDir = _testDirectory.storeDir();
            GraphDatabaseService        nonUpgradedStore = startNonUpgradableDatabaseWithFormat(storeDir, StandardV3_2.NAME);
            PointValue                  point            = pointValue(Cartesian, 1.0, 2.0);
            TransactionFailureException exception        = assertThrows(typeof(TransactionFailureException), () =>
            {
                using (Transaction transaction = nonUpgradedStore.BeginTx())
                {
                    Node node = nonUpgradedStore.CreateNode();
                    node.setProperty("a", new PointValue[] { point, point });
                    transaction.success();
                }
            });

            assertEquals("Current record format does not support POINT_PROPERTIES. Please upgrade your store to the format that support requested capability.", Exceptions.rootCause(exception).Message);
            nonUpgradedStore.Shutdown();

            GraphDatabaseService restartedOldFormatDatabase = startNonUpgradableDatabaseWithFormat(storeDir, StandardV3_2.NAME);

            using (Transaction transaction = restartedOldFormatDatabase.BeginTx())
            {
                Node node = restartedOldFormatDatabase.CreateNode();
                node.SetProperty("c", "d");
                transaction.success();
            }
            restartedOldFormatDatabase.Shutdown();
        }
    /// <summary>
    /// Converts the achievement to a multipart/form-data representation for POST and PUT queries
    /// It is designed to be compatible with the Gamification Framework
    /// </summary>
    /// <returns>The multipart/form-data with the correct fields</returns>
    public List <IMultipartFormSection> ToMultipartFormData()
    {
        List <IMultipartFormSection> body = new List <IMultipartFormSection>();

        body.Add(new MultipartFormDataSection("achievementid", ID));
        if (Name != "")
        {
            body.Add(new MultipartFormDataSection("achievementname", Name));
        }
        if (Description != "")
        {
            body.Add(new MultipartFormDataSection("achievementdesc", Description));
        }
        body.Add(new MultipartFormDataSection("achievementpointvalue", PointValue.ToString()));
        if (BadgeId != null && BadgeId != "")
        {
            body.Add(new MultipartFormDataSection("achievementbadgeid", BadgeId));
        }
        if (NotificationCheck)
        {
            body.Add(new MultipartFormDataSection("achievementnotificationcheck", true.ToString()));
        }
        if (NotificationMessage != "")
        {
            body.Add(new MultipartFormDataSection("achievementnotificationmessage", NotificationMessage));
        }

        return(body);
    }
示例#4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pointArraysOfCartesian()
        public virtual void PointArraysOfCartesian()
        {
            PointValue[] array = new PointValue[] { Values.pointValue(CoordinateReferenceSystem.Cartesian, -100.0, -100.0), Values.pointValue(CoordinateReferenceSystem.Cartesian, 25.0, 50.5) };
            int          numberOfBitsUsedForDoubles = 64;

            AssertPointArrayHasCorrectFormat(array, numberOfBitsUsedForDoubles);
        }
示例#5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenPopulatingWithNonUniquePoints() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowWhenPopulatingWithNonUniquePoints()
        {
            Config        config   = Config.defaults(stringMap(default_schema_provider.name(), _schemaIndex.providerName()));
            BatchInserter inserter = NewBatchInserter(config);
            PointValue    point    = Values.pointValue(CoordinateReferenceSystem.WGS84, 0.0, 0.0);

            inserter.createNode(MapUtil.map("prop", point), TestLabels.LABEL_ONE);
            inserter.createNode(MapUtil.map("prop", point), TestLabels.LABEL_ONE);
            inserter.CreateDeferredConstraint(TestLabels.LABEL_ONE).assertPropertyIsUnique("prop").create();
            inserter.Shutdown();

            GraphDatabaseService db = GraphDatabaseService(config);

            try
            {
                using (Transaction tx = Db.beginTx())
                {
                    IEnumerator <IndexDefinition> indexes = Db.schema().Indexes.GetEnumerator();
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertTrue(indexes.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    IndexDefinition index = indexes.next();
                    Org.Neo4j.Graphdb.schema.Schema_IndexState indexState = Db.schema().getIndexState(index);
                    assertEquals(Org.Neo4j.Graphdb.schema.Schema_IndexState.Failed, indexState);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    assertFalse(indexes.hasNext());
                    tx.Success();
                }
            }
            finally
            {
                Db.shutdown();
            }
        }
示例#6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createPointArrayPropertyOnLatestDatabase()
        internal virtual void CreatePointArrayPropertyOnLatestDatabase()
        {
            File       storeDir    = _testDirectory.storeDir();
            Label      pointNode   = Label.label("PointNode");
            string     propertyKey = "a";
            PointValue pointValue  = pointValue(Cartesian, 1.0, 2.0);

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(pointNode);
                node.SetProperty(propertyKey, new PointValue[] { pointValue, pointValue });
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                using (ResourceIterator <Node> nodes = restartedDatabase.FindNodes(pointNode))
                {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                    Node         node   = nodes.next();
                    PointValue[] points = ( PointValue[] )node.GetProperty(propertyKey);
                    assertThat(points, arrayWithSize(2));
                }
            }
            restartedDatabase.Shutdown();
        }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void createPointPropertyOnLatestDatabase()
        internal virtual void CreatePointPropertyOnLatestDatabase()
        {
            File       storeDir    = _testDirectory.storeDir();
            Label      pointNode   = Label.label("PointNode");
            string     propertyKey = "a";
            PointValue pointValue  = pointValue(Cartesian, 1.0, 2.0);

            GraphDatabaseService database = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction transaction = database.BeginTx())
            {
                Node node = database.CreateNode(pointNode);
                node.SetProperty(propertyKey, pointValue);
                transaction.Success();
            }
            database.Shutdown();

            GraphDatabaseService restartedDatabase = startDatabaseWithFormat(storeDir, Standard.LATEST_NAME);

            using (Transaction ignored = restartedDatabase.BeginTx())
            {
                assertNotNull(restartedDatabase.FindNode(pointNode, propertyKey, pointValue));
            }
            restartedDatabase.Shutdown();
        }
示例#8
0
    /// <summary>
    /// Projects raster values onto passed list of points from frustum viewField.
    /// Also updates mesh colors of meshes and points defined by meshList, meshIndices, pointIndices
    /// according to color1 to color2, value1 to value2 scale.
    /// </summary>
    private List <PointValue <byte> > Project(List <CachedVertex> points, Frustum viewField, byte[,] raster,
                                              float closest, float furthest, Vector3 curPos)
    {
        List <PointValue <byte> > result = new List <PointValue <byte> >();

        for (int i = 0; i < points.Count; i++)
        {
            Vector3    pt = points[i].point;
            ViewVector vv = viewField.ViewVec(pt);
            if (!viewField.FOV.Contains(vv))
            {
                throw new ArgumentOutOfRangeException("pt", "not contained in viewField.FOV");
            }

            /* Usual path - use sensor pixelmap
             * Vector2 coords = vv.Map<byte>(raster, viewField.FOV);
             * PointValue<byte> pv = new PointValue<byte>(pt, raster[(int)coords.x, (int)coords.y]);
             */

            // proximity path - use vertex coordinates
            Vector3 Vpos    = Vector(curPos, pt);
            float   distVal = (Vpos.magnitude - closest) / (furthest - closest);
            distVal = Mathf.Clamp01(distVal);
            byte scaledVal       = (byte)(distVal * 255f);
            PointValue <byte> pv = new PointValue <byte>(pt, scaledVal);

            // add pv to return
            result.Add(pv);
        }

        return(result);
    }
示例#9
0
        public static double getVal(PointValue val)
        {
            double res = 0;

            try {
                if (val.avSpecified)
                {
                    res = (double)val.av;
                }
                if (val.bvSpecified)
                {
                    res = val.bv.Value ? 1.0 : 0.0;
                }
                if (val.davSpecified)
                {
                    res = (double)val.dav;
                }
                if (val.ipvSpecified)
                {
                    res = (double)val.ipv;
                }
                if (val.pvSpecified)
                {
                    res = (double)val.pv;
                }
            } catch {
            }
            return(res);
        }
示例#10
0
//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");
        }
示例#11
0
    /// <summary>
    /// Converts the action to multipart/form-data in order to perform POST and PUT queries with the data
    /// It is designed to be compatible with the Gamfication Framework.
    /// </summary>
    /// <returns>The multipart/form-data with the filled fields</returns>
    public List <IMultipartFormSection> ToMultipartFormData()
    {
        List <IMultipartFormSection> body = new List <IMultipartFormSection>();

        body.Add(new MultipartFormDataSection("actionid", ID));
        if (Name != "")
        {
            body.Add(new MultipartFormDataSection("actionname", Name));
        }
        if (Description != "")
        {
            body.Add(new MultipartFormDataSection("actiondesc", Description));
        }
        body.Add(new MultipartFormDataSection("actionpointvalue", PointValue.ToString()));
        if (NotificationCheck)
        {
            body.Add(new MultipartFormDataSection("actionnotificationcheck", true.ToString()));
        }
        if (NotificationMessage != "")
        {
            body.Add(new MultipartFormDataSection("actionnotificationmessage", NotificationMessage));
        }

        return(body);
    }
示例#12
0
    private Position CollectItems(Position myPosition, Grid grid, Item[] myItems, ref List <Direction> directions)
    {
        var myConnectedItemsInQuest = myItems
                                      .Where(it => it.IsInQuest == true && it.x >= 0 && grid.ArePositionsConnected(it, myPosition))
                                      .ToList();

        while (directions.Count < MaxMoveCount && myConnectedItemsInQuest.Count > 0)
        {
            var cameFrom = ComputeBFS(fromPosition: myPosition);

            //Closest item
            PointValue[] shortestPath = new PointValue[100];
            Item         closestItem  = null;
            foreach (var item in myConnectedItemsInQuest)
            {
                var path = ComputePath(
                    from: new PointValue(myPosition),
                    goal: new PointValue(item),
                    cameFrom: cameFrom);
                if (path.Length < shortestPath.Length)
                {
                    shortestPath = path;
                    closestItem  = item;
                }
            }

            directions.AddRange(ComputeDirections(shortestPath));

            var collectedItemPosition = shortestPath.Last();
            myConnectedItemsInQuest.Remove(closestItem);
            myPosition = new Position(collectedItemPosition.x, collectedItemPosition.y);
        }

        return(myPosition);
    }
示例#13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void pointArraysOfMixedDimension()
        public virtual void PointArraysOfMixedDimension()
        {
            PointValue[] array = new PointValue[] { Values.pointValue(CoordinateReferenceSystem.Cartesian, Double.longBitsToDouble(0x1L), Double.longBitsToDouble(0x7L)), Values.pointValue(CoordinateReferenceSystem.Cartesian, Double.longBitsToDouble(0x1L), Double.longBitsToDouble(0x1L), Double.longBitsToDouble(0x4L)) };

            ICollection <DynamicRecord> records = new List <DynamicRecord>();

            _arrayStore.allocateRecords(records, array);
        }
示例#14
0
            protected internal override Header.Entry Entry <T1>(int index, string name, string typeSpec, Group group, Extractors extractors, Extractor <T1> idExtractor)
            {
                Type type = null;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.csv.reader.Extractor<?> extractor = null;
                Extractor <object>   extractor         = null;
                CSVHeaderInformation optionalParameter = null;

                if (string.ReferenceEquals(typeSpec, null))
                {                         // Property
                    type      = Type.Property;
                    extractor = extractors.String();
                }
                else
                {
                    Pair <string, string> split = SplitTypeSpecAndOptionalParameter(typeSpec);
                    typeSpec = split.First();
                    string optionalParameterString = split.Other();
                    if (!string.ReferenceEquals(optionalParameterString, null))
                    {
                        if (Extractors.PointExtractor.NAME.Equals(typeSpec))
                        {
                            optionalParameter = PointValue.parseHeaderInformation(optionalParameterString);
                        }
                        else if (Extractors.TimeExtractor.NAME.Equals(typeSpec) || Extractors.DateTimeExtractor.NAME.Equals(typeSpec))
                        {
                            optionalParameter = TemporalValue.parseHeaderInformation(optionalParameterString);
                        }
                    }

                    if (typeSpec.Equals(Type.StartId.name(), StringComparison.OrdinalIgnoreCase))
                    {
                        type      = Type.StartId;
                        extractor = idExtractor;
                    }
                    else if (typeSpec.Equals(Type.EndId.name(), StringComparison.OrdinalIgnoreCase))
                    {
                        type      = Type.EndId;
                        extractor = idExtractor;
                    }
                    else if (typeSpec.Equals(Type.Type.name(), StringComparison.OrdinalIgnoreCase))
                    {
                        type      = Type.Type;
                        extractor = extractors.String();
                    }
                    else if (IsRecognizedType(typeSpec))
                    {
                        throw new HeaderException("Unexpected relationship header type '" + typeSpec + "'");
                    }
                    else
                    {
                        type      = Type.Property;
                        extractor = ParsePropertyType(typeSpec, extractors);
                    }
                }
                return(new Header.Entry(name, type, group, extractor, optionalParameter));
            }
示例#15
0
 public Points(Level l, Point position, Sprite sprite, PointValue value) : base(l, position, sprite)
 {
     if (value == PointValue.p1up)
     {
         Level.Game.Lives++;
     }
     else
     {
         Level.Game.Points += 100 * (int)value;
     }
 }
示例#16
0
        public void Getters_ReturnPointValueParameters()
        {
            var dataType   = "dataType";
            var value      = "value";
            var pointValue = new PointValue(1, dataType, value);

            var point = new Point(2, pointValue);

            point.DataType.Should().Be(dataType);
            point.Value.Should().Be(value);
        }
示例#17
0
    /// <summary>
    /// Projects raster values onto passed list of points from frustum viewField.
    /// Also updates mesh colors of meshes and points defined by meshList, meshIndices, pointIndices
    /// according to color1 to color2, value1 to value2 scale.
    /// </summary>
    private List <PointValue <byte> > Project(List <CachedVertex> points, Frustum viewField, byte[,] raster,
                                              ReadOnlyCollection <SpatialMappingSource.SurfaceObject> meshList,
                                              Color32 color1, Color32 color2, Color32 defaultColor, byte value1, byte value2)
    {
        List <PointValue <byte> > result = new List <PointValue <byte> >();

        // setup coloring
        List <List <Color32> > newColoring  = new List <List <Color32> >();
        List <int>             colorIndices = new List <int>();

        for (int i = 0; i < points.Count; i++)
        {
            // setup coloring
            if (!colorIndices.Contains(points[i].meshIndex))
            {
                int            numVerts  = meshList[points[i].meshIndex].Filter.sharedMesh.vertexCount;
                List <Color32> newColors = new List <Color32>();

                // fill in default color
                for (int j = 0; j < numVerts; j++)
                {
                    newColors.Add(defaultColor);
                }

                newColoring.Add(newColors);
                colorIndices.Add(points[i].meshIndex);
            }

            Vector3    pt = points[i].point;
            ViewVector vv = viewField.ViewVec(pt);
            if (!viewField.FOV.Contains(vv))
            {
                throw new ArgumentOutOfRangeException("pt", "not contained in viewField.FOV");
            }

            Vector2           coords = vv.Map <byte>(raster, viewField.FOV);
            PointValue <byte> pv     = new PointValue <byte>(pt, raster[(int)coords.x, (int)coords.y]);

            // add pv to return
            result.Add(pv);

            // update mesh color
            float scaleVal   = (float)(pv.Value - value1) / (float)(value2 - value1);
            int   ColorIndex = colorIndices.FindIndex(x => x == points[i].meshIndex);
            newColoring[ColorIndex][points[i].pointIndex] = Color32.Lerp(color1, color2, scaleVal);
        }

        for (int i = 0; i < colorIndices.Count; i++)
        {
            meshList[colorIndices[i]].Filter.sharedMesh.SetColors(newColoring[i]);
        }

        return(result);
    }
示例#18
0
        public void Update_RaisesUpdated()
        {
            var dataType   = "dataType";
            var value      = "value";
            var pointValue = new PointValue(1, dataType, value);
            var point      = new Point(2, pointValue);

            point.MonitorEvents();
            point.Update();

            point.ShouldRaise("Updated");
        }
示例#19
0
        // Helper Methods
        private void GetDefaultPointValues()
        {
            _pointValues.Clear();

            foreach (DefaultPointValue pv in _dataContext.DefaultPointValues)
            {
                PointValue pointVal = new PointValue()
                {
                    Index = pv.ID, Points = pv.Points
                };
                _pointValues.Add(pointVal);
            }
        }
示例#20
0
        private void AssertSingleCorrectHit(GraphDatabaseService db, PointValue point)
        {
            ResourceIterator <Node> nodes = Db.findNodes(TestLabels.LABEL_ONE, "prop", point);

//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertTrue(nodes.hasNext());
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            Node   node = nodes.next();
            object prop = node.GetProperty("prop");

            assertEquals(point, prop);
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
            assertFalse(nodes.hasNext());
        }
示例#21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustSelectSpatialForRangeGeometricPredicate() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustSelectSpatialForRangeGeometricPredicate()
        {
            // given
            assumeTrue(HasSpatialSupport());
            PointValue from = Values.pointValue(CoordinateReferenceSystem.Cartesian, 1.0, 1.0);
            PointValue to   = Values.pointValue(CoordinateReferenceSystem.Cartesian, 2.0, 2.0);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.internal.kernel.api.IndexQuery.RangePredicate<?> geometryRange = org.neo4j.internal.kernel.api.IndexQuery.range(PROP_KEY, from, true, to, false);
            IndexQuery.RangePredicate <object> geometryRange = IndexQuery.range(PROP_KEY, from, true, to, false);

            // then
            VerifyQueryWithCorrectReader(_readers[SPATIAL], geometryRange);
        }
示例#22
0
    static void Example6_ValueTypes()
    {
        PointValue p1 = new PointValue();

        p1.X = 7;

        PointValue p2 = p1;

        Console.WriteLine(p1.X);
        Console.WriteLine(p2.X);

        p1.X = 9;
        Console.WriteLine(p1.X);
        Console.WriteLine(p2.X);
    }
示例#23
0
        public PointValue PointValueConverter(tblPointValue dbpointvalue)
        {
            if (dbpointvalue == null)
            {
                return(null);
            }

            var pointvalue = new PointValue
            {
                DataTime  = dbpointvalue.DataTime,
                DataValue = dbpointvalue.DataValue,
                theIndex  = dbpointvalue.theIndex
            };

            return(pointvalue);
        }
示例#24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldExtractPoint()
        internal virtual void ShouldExtractPoint()
        {
            // GIVEN
            Extractors extractors = new Extractors(',');
            PointValue value      = Values.pointValue(CoordinateReferenceSystem.WGS84, 13.2, 56.7);

            // WHEN
            char[] asChars = "Point{latitude: 56.7, longitude: 13.2}".ToCharArray();
            Extractors.PointExtractor extractor = extractors.Point();
            string headerInfo = "{crs:WGS-84}";

            extractor.Extract(asChars, 0, asChars.Length, false, PointValue.parseHeaderInformation(headerInfo));

            // THEN
            assertEquals(value, extractor.ValueConflict);
        }
示例#25
0
    private PointValue[] ComputePath(PointValue from, PointValue goal, Dictionary <PointValue, PointValue?> cameFrom)
    {
        PointValue?current = goal;
        var        path    = new List <PointValue>();

        while (current != null && current.Value.AreSame(from) == false)
        {
            path.Add(current.Value);
            current = cameFrom[current.Value];
        }

        path.Add(from);

        path.Reverse();

        return(path.ToArray());
    }
示例#26
0
        public void Calculate_xDivisor_Test()
        {
            int xPositiveLength = 350;
            var date1           = new DateTime(2014, 6, 14, 15, 20, 00);
            var date2           = new DateTime(2014, 6, 17, 15, 25, 00);
            var date3           = new DateTime(2014, 6, 17, 15, 35, 00);
            var pointvalue1     = new PointValue {
                DataTime = date1, DataValue = 20.5, theIndex = 1
            };
            var pointvalue2 = new PointValue {
                DataTime = date2, DataValue = 22.5, theIndex = 1
            };
            var pointvalue3 = new PointValue {
                DataTime = date3, DataValue = 19.22, theIndex = 1
            };
            var pointvalues = new List <PointValue>();

            pointvalues.Add(pointvalue1);
            pointvalues.Add(pointvalue2);
            pointvalues.Add(pointvalue3);
            var highestMinuteDifference = (date3 - date1).TotalMinutes / xPositiveLength;
            var expectedDivisor         = Convert.ToInt32(Math.Ceiling(highestMinuteDifference));
            var divisor = facade.GetDBLogic().CalculateXDivisor(pointvalues);

            Assert.AreEqual(expectedDivisor, divisor);


            var date12       = new DateTime(2014, 6, 13, 10, 20, 00);
            var date22       = new DateTime(2014, 6, 17, 15, 25, 00);
            var pointvalue12 = new PointValue {
                DataTime = date1, DataValue = 20.5, theIndex = 1
            };
            var pointvalue22 = new PointValue {
                DataTime = date2, DataValue = 22.5, theIndex = 1
            };
            var pointvalues2 = new List <PointValue>();

            pointvalues2.Add(pointvalue12);
            pointvalues2.Add(pointvalue22);

            var highestMinuteDifference2 = (date22 - date12).TotalMinutes / xPositiveLength;
            var expectedDivisor2         = Convert.ToInt32(Math.Ceiling(highestMinuteDifference));
            var divisor2 = facade.GetDBLogic().CalculateXDivisor(pointvalues2);

            Assert.AreEqual(expectedDivisor2, divisor2);
        }
示例#27
0
        /// <summary>
        /// Builds a DCT-interpolated image from its string representation.
        /// </summary>
        /// <param name="fitstring">the string containing the representation of the image.</param>
        /// <remarks>
        /// Syntax for string representation of DCT-coded images:<br />
        /// <c>dct:<i>width</i>,<i>height</i>,<i>bitsperpixel</i>,<i>xwaves</i>,<i>ywaves</i>{;<i>x</i>,<i>y</i>,<i>value</i>}</c><br />
        /// <example>dct:1280,1024,8,2,2;100,100,180;1000,120,220;1004,900,200;180,940,200</example>
        /// </remarks>
        public static DCTInterpolationImage FromDCTString(string fitstring)
        {
            lock (s_LockObj)
                if (s_LastImageText != null && fitstring == s_LastImageText)
                {
                    return(s_LastImage);
                }
            if (fitstring.ToLower().StartsWith(DCTString) == false)
            {
                throw new Exception("DCT coding string must begin with \"dct:\".");
            }
            string[] tokens  = fitstring.Substring(DCTString.Length).Split(';');
            string[] htokens = tokens[0].Split(',');
            if (htokens.Length != 5)
            {
                throw new Exception("DCT string must contain width, height, bitsperpixel, xwaves, ywaves.");
            }
            SySal.Imaging.ImageInfo info = new ImageInfo();
            info.Width        = ushort.Parse(htokens[0]);
            info.Height       = ushort.Parse(htokens[1]);
            info.BitsPerPixel = ushort.Parse(htokens[2]);
            info.PixelFormat  = PixelFormatType.GrayScale8;
            int xwaves = int.Parse(htokens[3]);
            int ywaves = int.Parse(htokens[4]);
            int i;

            PointValue [] pvals = new PointValue[tokens.Length - 1];
            for (i = 0; i < pvals.Length; i++)
            {
                htokens = tokens[i + 1].Split(',');
                if (htokens.Length != 3)
                {
                    throw new Exception("Error in point value specification " + i + ": point value syntax is x,y,value.");
                }
                pvals[i].X     = ushort.Parse(htokens[0]);
                pvals[i].Y     = ushort.Parse(htokens[1]);
                pvals[i].Value = int.Parse(htokens[2]);
            }
            lock (s_LockObj)
            {
                s_LastImageText = fitstring;
                s_LastImage     = new DCTInterpolationImage(info, xwaves, ywaves, pvals);
                return(s_LastImage);
            }
        }
示例#28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHandlePoints()
        public virtual void ShouldHandlePoints()
        {
            // Given
            PointValue pointValue = Values.pointValue(CoordinateReferenceSystem.WGS84, 1.0, 2.0);

            // When
            pointValue.WriteTo(_converter);

            // Then
            object value = _converter.value();

            assertThat(value, instanceOf(typeof(Point)));
            Point point = ( Point )value;

            assertThat(point.Coordinate.Coordinate[0], equalTo(1.0));
            assertThat(point.Coordinate.Coordinate[1], equalTo(2.0));
            assertThat(point.CRS.Code, equalTo(4326));
        }
示例#29
0
 private Direction GetDirectionFrom(PointValue from, PointValue to)
 {
     if (from.x == to.x - 1)
     {
         return(Direction.RIGHT);
     }
     if (from.x == to.x + 1)
     {
         return(Direction.LEFT);
     }
     if (from.y == to.y - 1)
     {
         return(Direction.DOWN);
     }
     if (from.y == to.y + 1)
     {
         return(Direction.UP);
     }
     throw new NotSupportedException();
 }
示例#30
0
        public void PointValueList_To_PointCollection_Is_Successful()
        {
            int divisor = 1;

            var date1 = new DateTime(2014, 6, 17, 15, 20, 00);
            var date2 = new DateTime(2014, 6, 17, 15, 25, 00);
            var date3 = new DateTime(2014, 6, 17, 15, 35, 00);

            var pointvalue1 = new PointValue {
                DataTime = date1, DataValue = 20.5, theIndex = 1
            };
            var pointvalue2 = new PointValue {
                DataTime = date2, DataValue = 22.5, theIndex = 1
            };
            var pointvalue3 = new PointValue {
                DataTime = date3, DataValue = 19.22, theIndex = 1
            };
            var pointvalues = new List <PointValue>();

            pointvalues.Add(pointvalue1);
            pointvalues.Add(pointvalue2);
            pointvalues.Add(pointvalue3);

            var pointcollection = facade.GetDBLogic().PointValuesToPointCollection(pointvalues);

            Assert.AreEqual(0, pointcollection.PointCollection[0].X);

            var y1 = facade.GetDBLogic().GetChartPoint(0, pointvalue1.DataValue, divisor, divisor);

            Assert.AreEqual(y1.Y, pointcollection.PointCollection[0].Y);

            Assert.AreEqual(5, pointcollection.PointCollection[1].X);
            var y2 = facade.GetDBLogic().GetChartPoint(0, pointvalue2.DataValue, divisor, divisor);

            Assert.AreEqual(y2.Y, pointcollection.PointCollection[1].Y);

            Assert.AreEqual(15, pointcollection.PointCollection[2].X);
            var y3 = facade.GetDBLogic().GetChartPoint(0, pointvalue3.DataValue, divisor, divisor);

            Assert.AreEqual(y3.Y, pointcollection.PointCollection[2].Y);
        }
 public ExchangeRate(XmlNode xmlNode)
 {
     XmlNodeList quotedCurrencyPairNodeList = xmlNode.SelectNodes("quotedCurrencyPair");
     if (quotedCurrencyPairNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in quotedCurrencyPairNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 quotedCurrencyPairIDRef = item.Attributes["id"].Name;
                 QuotedCurrencyPair ob = QuotedCurrencyPair();
                 IDManager.SetID(quotedCurrencyPairIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 quotedCurrencyPairIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 quotedCurrencyPair = new QuotedCurrencyPair(item);
             }
         }
     }
     
 
     XmlNodeList rateNodeList = xmlNode.SelectNodes("rate");
     if (rateNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in rateNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 rateIDRef = item.Attributes["id"].Name;
                 PositiveDecimal ob = PositiveDecimal();
                 IDManager.SetID(rateIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 rateIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 rate = new PositiveDecimal(item);
             }
         }
     }
     
 
     XmlNodeList spotRateNodeList = xmlNode.SelectNodes("spotRate");
     if (spotRateNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in spotRateNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 spotRateIDRef = item.Attributes["id"].Name;
                 PositiveDecimal ob = PositiveDecimal();
                 IDManager.SetID(spotRateIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 spotRateIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 spotRate = new PositiveDecimal(item);
             }
         }
     }
     
 
     XmlNodeList forwardPointsNodeList = xmlNode.SelectNodes("forwardPoints");
     if (forwardPointsNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in forwardPointsNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 forwardPointsIDRef = item.Attributes["id"].Name;
                 XsdTypeDecimal ob = XsdTypeDecimal();
                 IDManager.SetID(forwardPointsIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 forwardPointsIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 forwardPoints = new XsdTypeDecimal(item);
             }
         }
     }
     
 
     XmlNodeList pointValueNodeList = xmlNode.SelectNodes("pointValue");
     if (pointValueNodeList.Count > 1 )
     {
             throw new Exception();
     }
     
     foreach (XmlNode item in pointValueNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 pointValueIDRef = item.Attributes["id"].Name;
                 PointValue ob = PointValue();
                 IDManager.SetID(pointValueIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 pointValueIDRef = item.Attributes["href"].Name;
             }
             else
             {
                 pointValue = new PointValue(item);
             }
         }
     }
     
 
     XmlNodeList crossRateNodeList = xmlNode.SelectNodes("crossRate");
     
     foreach (XmlNode item in crossRateNodeList)
     {
         if (item.Attributes["href"] != null || item.Attributes["id"] == null) 
         {
             if (item.Attributes["id"] != null) 
             {
                 crossRateIDRef = item.Attributes["id"].Name;
                 List<CrossRate> ob = new List<CrossRate>();
                 ob.Add(new CrossRate(item));
                 IDManager.SetID(crossRateIDRef, ob);
             }
             else if (item.Attributes.ToString() == "href")
             {
                 crossRateIDRef = item.Attributes["href"].Name;
             }
             else
             {
             crossRate.Add(new CrossRate(item));
             }
         }
     }
     
 
 }
示例#32
0
文件: Form1.cs 项目: bashis/MyGraphic
 /// <summary>
 /// Поиск значения функции по координатам в списке. Если точки с такими координатами нет, она будет добавлена.
 /// </summary>
 /// <param name="x">координата X</param>
 /// <param name="y">координата Y</param>
 /// <returns></returns>
 double GetValue(double x, double y)
 {
     for (int i = 0; i < ValueList.Count; i++) //Проходим по всем элементам в списке
     {
         if (ValueList[i].X == x && ValueList[i].Y == y) //Если нашли точку с данными координатами X и Y
         {
             return ValueList[i].Value; //Возвращаем значение функции в ней
         }
     }
     //Если прошли все точки, а подходящую так и не нашли
     PointValue newValue = new PointValue(x, y); //Объявляем новую точку по данным координатам
     ValueList.Add(newValue); //Добавляем её в список
     return newValue.Value; //Возвращаем значение функции в неё
 }
        /// <summary>
        /// This is needed when the points passed in could have values greater than zero at the edge.  This creates an extra ring of
        /// points that always have a value of zero.  That way any mesh made out of this won't just stop abruptly
        /// </summary>
        private static Tuple<PointValue[], TriangleIndexed[]> GetDelaunay_ExpandRing(PointValue[] points, double heightMult)
        {
            if (points.Length == 0)
            {
                return null;
            }

            // Get the average min distance between the points
            List<Tuple<int, int, double>> distances = new List<Tuple<int, int, double>>();

            for (int outer = 0; outer < points.Length - 1; outer++)
            {
                for (int inner = outer + 1; inner < points.Length; inner++)
                {
                    double distance = (points[outer].Point - points[inner].Point).LengthSquared;

                    distances.Add(Tuple.Create(outer, inner, distance));
                }
            }

            double avgDist;
            if (distances.Count == 0)
            {
                avgDist = points[0].Point.ToVector().Length;
                if (Math1D.IsNearZero(avgDist))
                {
                    avgDist = .1;
                }
            }
            else
            {
                avgDist = Enumerable.Range(0, points.Length).
                    Select(o => distances.
                        Where(p => p.Item1 == o || p.Item2 == o).       // get the disances that mention this index
                        Min(p => p.Item3)).     // only keep the smallest of those distances
                    Average();      // get the average of all the mins

                avgDist = Math.Sqrt(avgDist);
            }

            double maxDist = points.Max(o => o.Point.ToVector().LengthSquared);
            maxDist = Math.Sqrt(maxDist);

            double radius = maxDist + avgDist;

            // Create a ring of points at that distance
            List<PointValue> expandedPoints = new List<PointValue>(points);

            int numExtra = GetNumExtraPoints(points.Length);

            expandedPoints.AddRange(Math2D.GetCircle_Cached(numExtra).Select(o => new PointValue() { Point = new Point(o.X * radius, o.Y * radius), Value = 0 }));

            // Get the delaunay of all these points
            TriangleIndexed[] triangles = Math2D.GetDelaunayTriangulation(expandedPoints.Select(o => o.Point).ToArray(), expandedPoints.Select(o => o.Point.ToPoint3D() + new Vector3D(0, 0, o.Value * heightMult)).ToArray());

            // Exit Function
            return Tuple.Create(expandedPoints.ToArray(), triangles);
        }