Exemplo n.º 1
0
        private static IShapeCollection ExtractPoints(System.IO.BinaryReader shpReader, ShxReader shxReader, List <Indexing.ShpIndex> indexes)
        {
            List <EsriPoint> geometries = new List <EsriPoint>(indexes.Count);

            for (int i = 0; i < indexes.Count; i++)
            {
                int offset, contentLength;

                shxReader.GetRecord(indexes[i].RecordNumber, out offset, out contentLength);

                geometries[i] = PointReader.Read(shpReader, offset, contentLength);
            }

            return(new ShapeCollection <EsriPoint>(geometries));
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var config = new PointReadWriteConfig();
            var activeDirectoryHelper = new ActiveDirectoryHelper(config, new TokenCacheFactory());

            var pointReader = new PointReader(config, activeDirectoryHelper);
            var systemGuid  = Guid.Parse(ConfigurationManager.AppSettings["SystemGuid"]);

            //Point id format is <pointname.property> ex: blr_sp.pv
            var readResponse = pointReader.ReadPoint(systemGuid, "CBC_VAV2RoomTemp.presentvalue");

            var    pointWriter       = new PointWriter(config, activeDirectoryHelper);
            object pointValueToWrite = 0; //put what ever value you want to write

            //Point id format is <pointname.property> ex: blr_sp.sp
            var writeResponse = pointWriter.WritePoint(systemGuid, "PUT YOUR POINT ID HERE", pointValueToWrite);

            Console.ReadLine();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads data from the SortedTreeEngine with the provided read options and server side filters.
        /// </summary>
        /// <param name="readerOptions">read options supplied to the reader. Can be null.</param>
        /// <param name="keySeekFilter">a seek based filter to follow. Can be null.</param>
        /// <param name="keyMatchFilter">a match based filer to follow. Can be null.</param>
        /// <returns>A stream that will read the specified data.</returns>
        public override TreeStream <TKey, TValue> Read(SortedTreeEngineReaderOptions readerOptions, SeekFilterBase <TKey> keySeekFilter, MatchFilterBase <TKey, TValue> keyMatchFilter)
        {
            if (m_reader != null)
            {
                throw new Exception("Sockets do not support concurrent readers. Dispose of old reader.");
            }

            m_stream.Write((byte)ServerCommand.Read);
            if (keySeekFilter == null)
            {
                m_stream.Write(false);
            }
            else
            {
                m_stream.Write(true);
                m_stream.Write(keySeekFilter.FilterType);
                keySeekFilter.Save(m_stream);
            }

            if (keyMatchFilter == null)
            {
                m_stream.Write(false);
            }
            else
            {
                m_stream.Write(true);
                m_stream.Write(keyMatchFilter.FilterType);
                keyMatchFilter.Save(m_stream);
            }

            if (readerOptions == null)
            {
                m_stream.Write(false);
            }
            else
            {
                m_stream.Write(true);
                readerOptions.Save(m_stream);
            }
            m_stream.Flush();


            var command = (ServerResponse)m_stream.ReadUInt8();

            switch (command)
            {
            case ServerResponse.UnhandledException:
                string exception = m_stream.ReadString();
                throw new Exception("Server UnhandledExcetion: \n" + exception);

            case ServerResponse.UnknownOrCorruptSeekFilter:
                throw new Exception("Server does not recgonize the seek filter");

            case ServerResponse.UnknownOrCorruptMatchFilter:
                throw new Exception("Server does not recgonize the match filter");

            case ServerResponse.UnknownOrCorruptReaderOptions:
                throw new Exception("Server does not recgonize the reader options");

            case ServerResponse.SerializingPoints:
                break;

            case ServerResponse.ErrorWhileReading:
                exception = m_stream.ReadString();
                throw new Exception("Server Error While Reading: \n" + exception);

            default:
                throw new Exception("Unknown server response: " + command.ToString());
            }

            m_reader = new PointReader(m_encodingMode, m_stream, () => m_reader = null);
            return(m_reader);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            foreach (string path in args)
            {
                PointReader ps = load(path);
                output(String.Format("   Number of Points:   {0}\n", ps.getNumPoints()));

                {
                    Bounds b = ps.getBounds();
                    output(String.Format("   Bounds Min:         {0} {1} {2}\n", b.x.min, b.y.min, b.z.min));
                    output(String.Format("   Bounds Max:         {0} {1} {2}\n", b.x.max, b.y.max, b.z.max));
                }
                output(String.Format("   Scale:              {0} {1} {2}\n", ps.getScale()[0], ps.getScale()[2], ps.getScale()[2]));
                output(String.Format("   Offset:             {0} {1} {2}\n", ps.getOffset()[0], ps.getOffset()[2], ps.getOffset()[2]));

                {
                    PointInfo pi = ps.getPointInfo();
                    output(String.Format("   Number of Channels: {0}\n", ps.getNumChannels()));
                    output("   Supported Fields:  ");
                    for (uint i = 0; i < pi.getNumChannels(); i += 1)
                    {
                        output(" " + pi.getChannel(i).getName());
                    }
                    output("\n");
                }
                output(String.Format("   Spatial Reference:  {0}\n", ps.getWKT()));

                if (true /*options.metadata*/)
                {
                    Metadata meta = new Metadata();
                    ps.loadMetadata(meta, false);
                    if (meta.getNumRecords() != 0)
                    {
                        output(String.Format("   Metadata:           {0}\n", meta.getNumRecords()));
                        for (uint i = 0; i < meta.getNumRecords(); i += 1)
                        {
                            output(String.Format("      {0} ({1}):\n", meta.getKey(i), meta.getDescription(i)));
                            switch (meta.getDataType(i))
                            {
                            case MetadataDataType.METADATA_DATATYPE_STRING:
                                output(String.Format("         '{0}'\n", meta.getValue(i)));
                                break;

                            case MetadataDataType.METADATA_DATATYPE_BLOB:
                                output(String.Format("         (blob of {0} bytes)\n", meta.getValueLength(i)));
                                break;

                            case MetadataDataType.METADATA_DATATYPE_REAL_ARRAY:
                                output(String.Format("         {{"));
                                double[] values = (double [])meta.getValue(i);
                                for (uint j = 0; j < meta.getValueLength(i); j += 1)
                                {
                                    output(String.Format(" {0}", values[j]));
                                }
                                output(String.Format(" }}\n"));
                                break;
                            }
                        }
                    }
                    else
                    {
                        output("   Metadata:           None\n");
                    }

                    if (ps.getNumClassIdNames() != 0)
                    {
                        output(String.Format("   ClassId Names:      {0}\n", ps.getNumClassIdNames()));
                        foreach (string name in ps.getClassIdNames())
                        {
                            output(String.Format("      {0}\n", name));
                        }
                    }
                    else
                    {
                        output("   ClassId Names:      None\n");
                    }
                }

                if (true /*options.bounds*/)
                {
                    PointInfo pi = new PointInfo();
                    pi.init(3);
                    pi.getChannel(0).init(ps.getChannel(LidarDSDK.CHANNEL_NAME_X));
                    pi.getChannel(1).init(ps.getChannel(LidarDSDK.CHANNEL_NAME_Y));
                    pi.getChannel(2).init(ps.getChannel(LidarDSDK.CHANNEL_NAME_Z));

                    PointData buffer = new PointData();
                    buffer.init(pi, 4096);

                    ChannelData x = buffer.getChannel(0);
                    ChannelData y = buffer.getChannel(1);
                    ChannelData z = buffer.getChannel(2);

                    UInt64 numPoints = 0;

                    PointIterator iter   = ps.createIterator(Bounds.Huge(), 1.0, pi, null);
                    Bounds        bounds = new Bounds();
                    uint          count  = iter.getNextPoints(buffer);
                    while (count != 0)
                    {
                        numPoints += count;
                        for (uint i = 0; i < count; i += 1)
                        {
                            bounds.grow(x.getValue(i), y.getValue(i), z.getValue(i));
                        }
                        count = iter.getNextPoints(buffer);
                    }

                    Bounds b = bounds;
                    output(String.Format("   # of Points Read:   {0}\n", numPoints));
                    output("Real Bounds:\n");
                    output(String.Format("   Bounds Min:         {0} {1} {2}\n", b.x.min, b.y.min, b.z.min));
                    output(String.Format("   Bounds Max:         {0} {1} {2}\n", b.x.max, b.y.max, b.z.max));
                }
            }
        }