public static void Run()
        {
            //ExStart: WriteGeoJsonToStream
            using (var memoryStream = new MemoryStream())
            {
                using (var layer = VectorLayer.Create(AbstractPath.FromStream(memoryStream), Drivers.GeoJson))
                {
                    layer.Attributes.Add(new FeatureAttribute("name", AttributeDataType.String));
                    layer.Attributes.Add(new FeatureAttribute("age", AttributeDataType.Integer));

                    Feature firstFeature = layer.ConstructFeature();
                    firstFeature.Geometry = new Point(33.97, -118.25);
                    firstFeature.SetValue("name", "John");
                    firstFeature.SetValue("age", 23);
                    layer.Add(firstFeature);

                    Feature secondFeature = layer.ConstructFeature();
                    secondFeature.Geometry = new Point(35.81, -96.28);
                    secondFeature.SetValue("name", "Mary");
                    secondFeature.SetValue("age", 54);
                    layer.Add(secondFeature);
                }
                Console.WriteLine(Encoding.UTF8.GetString(memoryStream.ToArray()));
            }
            //ExEnd: WriteGeoJsonToStream
        }
Example #2
0
            public override bool accept(AbstractPath ap)
            {
                Path child = (Path)ap;

                Log.debug("accept:" + child);
                return(base.accept(child));
            }
Example #3
0
 public ChildGetterBrowserBackgrounAction(BrowserController controller,
                                          AbstractPath path,
                                          List <AbstractPath> isLoadingListingInBackground)
     : base(controller)
 {
     _controller = controller;
     _path       = path;
     _isLoadingListingInBackground = isLoadingListingInBackground;
 }
Example #4
0
 public PathMover(BaseMovable toMove, AbstractPath path, ICompleteAble movementComplete)
 {
     MovementComplete       = movementComplete;
     ToMove                 = toMove;
     Path                   = path;
     ToMove.Moving          = true;
     ToMove.MovingDirection = new Vector2();
     NextPosition           = new Point();
 }
Example #5
0
        private AbstractPath GetPath(TreePathReference path)
        {
            AbstractPath result = _controller.getSession().cache().lookup(path);

            if (null == result)
            {
                // cache is being updated
                result = path.Unique;
            }
            return(result);
        }
Example #6
0
        public IEnumerable <TreePathReference> ChildrenGetter(object reference)
        {
            AbstractPath   path = ((TreePathReference)reference).Unique;
            AttributedList list;

            lock (_isLoadingListingInBackground)
            {
                if (!_isLoadingListingInBackground.Contains(path))
                {
                    if (path.isCached())
                    {
                        list = path.cache().get(path.getReference(), _controller.FilenameComparator,
                                                _controller.FilenameFilter);
                        for (int i = 0; i < list.size(); i++)
                        {
                            yield return(new TreePathReference((Path)list.get(i)));
                        }
                        yield break;
                    }
                }
                _isLoadingListingInBackground.Add(path);
                // Reloading a workdir that is not cached yet would cause the interface to freeze;
                // Delay until path is cached in the background


                // switch to blocking children fetching
                //path.childs();

                _controller.Background(new ChildGetterBrowserBackgrounAction(_controller, path,
                                                                             _isLoadingListingInBackground));
            }
            list = path.cache().get(path.getReference(), _controller.FilenameComparator, _controller.FilenameFilter);

            /*
             * if (list.size() == 0)
             * {
             *  yield return
             *      new TreePathReference(PathFactory.createPath(_controller.getSession(), "Loading...",
             *                                                   AbstractPath.FILE_TYPE));
             * }
             * else
             * {*/
            for (int i = 0; i < list.size(); i++)
            {
                yield return(new TreePathReference((Path)list.get(i)));
            }
            //}
            yield break;
        }
Example #7
0
        public static void Run()
        {
            //ExStart: ReadGeoJsonFromStream
            const string geoJson = @"{""type"":""FeatureCollection"",""features"":[
                {""type"":""Feature"",""geometry"":{""type"":""Point"",""coordinates"":[0, 1]},""properties"":{""name"":""John""}},
                {""type"":""Feature"",""geometry"":{""type"":""Point"",""coordinates"":[2, 3]},""properties"":{""name"":""Mary""}}
            ]}";

            using (var memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(geoJson)))
                using (var layer = VectorLayer.Open(AbstractPath.FromStream(memoryStream), Drivers.GeoJson))
                {
                    Console.WriteLine(layer.Count);                        // 2
                    Console.WriteLine(layer[1].GetValue <string>("name")); // Mary
                }
            //ExEnd: ReadGeoJsonFromStream
        }
 public override bool accept(AbstractPath ap)
 {
     Path child = (Path) ap;
     Log.debug("accept:" + child);
     if (child.getLocal().exists())
     {
         if (child.attributes().isFile())
         {
             if (child.getLocal().attributes().getSize() == 0)
             {
                 // Do not prompt for zero sized files
                 return false;
             }
         }
         return base.accept(child);
     }
     return false;
 }
        public void RoundtripsAbstractPathInRootWithNoGrafts()
        {
            var builder = new StorageHierarchiesBuilder(new StubFileSystemApi());
            var root    = builder.CreateNode(@"C:\Root", FileSystemCasing.CasePreservingInsensitive);

            builder.AddNamedRoot("SimpleRoot", root);
            var storage = builder.BuildHierarchies();

            var qualifiedPath        = new QualifiedPath(root, RelativePath.CreateFromSegments("some", "filepath.txt"));
            var expectedAbstractPath = new AbstractPath(storage.NamedRoots.Single(), RelativePath.CreateFromSegments("some", "filepath.txt"));

            var abstractPath = storage.MapToAbstractPath(qualifiedPath);

            Assert.That(abstractPath, Is.EqualTo(expectedAbstractPath).Using(default(AbstractPath.DefaultEqualityComparer)));
            Assert.That(storage.MapFromAbstractPath(abstractPath),
                        Is.EqualTo(qualifiedPath)
                        .Using(default(QualifiedPath.DefaultEqualityComparer)));
        }
        public override bool accept(AbstractPath ap)
        {
            Path child = (Path)ap;

            Log.debug("accept:" + child);
            if (child.getLocal().exists())
            {
                if (child.attributes().isFile())
                {
                    if (child.getLocal().attributes().getSize() == 0)
                    {
                        // Do not prompt for zero sized files
                        return(false);
                    }
                }
                return(base.accept(child));
            }
            return(false);
        }
Example #11
0
            public override bool accept(AbstractPath ap)
            {
                Path child = (Path)ap;

                Log.debug("accept:" + child);
                if (child.exists())
                {
                    if (child.attributes().getSize() == -1)
                    {
                        child.readSize();
                    }
                    if (child.getSession().isTimestampSupported())
                    {
                        if (child.attributes().getModificationDate() == -1)
                        {
                            child.readTimestamp();
                        }
                    }
                    return(base.accept(child));
                }
                return(false);
            }
 public bool Equals(AbstractPath <EdgeType, PointType> path1, AbstractPath <EdgeType, PointType> path2)
 {
     if (path1 == null && path2 == null)
     {
         return(true);
     }
     else if (path1 == null | path2 == null)
     {
         return(false);
     }
     else if (path1.ListPathEdges == null || path2.ListPathEdges == null)
     {
         return(false);
     }
     else if (path1.ListPathEdges.Count != path2.ListPathEdges.Count)
     {
         return(false);
     }
     else
     {
         return(path1.ListPathEdges.SequenceEqual(path2.ListPathEdges));
     }
 }
Example #13
0
 public TreePathReference(AbstractPath path)
 {
     _path = path;
 }
Example #14
0
 public void IncreasePathProgress(AbstractPath _path)
 {
     currentPathProgress += Time.deltaTime / _path.pathDuration;
 }
Example #15
0
 public bool IsNewPath(AbstractPath _path)
 {
     // TODO: Return true if the path is new
     return(false);
 }
Example #16
0
        public void RefreshObject(AbstractPath path)
        {
            AsyncDelegate refreshAction = () => View.RefreshBrowserObject(new TreePathReference(path));

            Invoke(refreshAction);
        }
Example #17
0
 protected override PathReference create(AbstractPath ap)
 {
     return(new TreePathReference(ap));
 }
 public int GetHashCode(AbstractPath <EdgeType, PointType> obj)
 {
     return(0); //TODO Костыль GetHashCode
 }
 public virtual bool accept(AbstractPath ap)
 {
     return true;
 }
Example #20
0
 public ChildGetterBrowserBackgrounAction(BrowserController controller,
     AbstractPath path,
     List<AbstractPath> isLoadingListingInBackground)
     : base(controller)
 {
     _controller = controller;
     _path = path;
     _isLoadingListingInBackground = isLoadingListingInBackground;
 }
Example #21
0
 public TreePathReference(AbstractPath reference)
 {
     _reference = reference;
 }
Example #22
0
 public virtual bool accept(AbstractPath ap)
 {
     return(true);
 }
Example #23
0
 public TreePathReference(AbstractPath reference)
 {
     _reference = reference;
 }
Example #24
0
 protected override PathReference create(AbstractPath ap)
 {
     return new TreePathReference(ap);
 }
Example #25
0
 public override bool accept(AbstractPath ap)
 {
     Path child = (Path) ap;
     Log.debug("accept:" + child);
     if (child.exists())
     {
         if(child.attributes().getSize() == -1) {
             child.readSize();
         }
         if(child.getSession().isTimestampSupported()) {
             if(child.attributes().getModificationDate() == -1) {
                 child.readTimestamp();
             }
         }
         return base.accept(child);
     }
     return false;
 }
Example #26
0
 public override bool accept(AbstractPath ap)
 {
     Path child = (Path) ap;
     Log.debug("accept:" + child);
     return base.accept(child);
 }