Example #1
0
        // should only be called *once*
        public bool setup(uint num_items, LASitem[] items, LASzip laszip = null)
        {
            // is laszip exists then we must use its items
            if (laszip != null)
            {
                if (num_items != laszip.num_items)
                {
                    return(false);
                }
                if (items != laszip.items)
                {
                    return(false);
                }
            }

            // create entropy decoder (if requested)
            dec = null;
            if (laszip != null && laszip.compressor != 0)
            {
                switch (laszip.coder)
                {
                case LASzip.CODER_ARITHMETIC: dec = new ArithmeticDecoder(); break;

                default: return(false);                        // entropy decoder not supported
                }
            }

            // initizalize the readers
            readers     = null;
            num_readers = num_items;

            // disable chunking
            chunk_size = uint.MaxValue;

            // always create the raw readers
            readers_raw = new LASreadItem[num_readers];
            for (int i = 0; i < num_readers; i++)
            {
                switch (items[i].type)
                {
                case LASitem.Type.POINT10: readers_raw[i] = new LASreadItemRaw_POINT10(); break;

                case LASitem.Type.GPSTIME11: readers_raw[i] = new LASreadItemRaw_GPSTIME11(); break;

                case LASitem.Type.RGB12: readers_raw[i] = new LASreadItemRaw_RGB12(); break;

                case LASitem.Type.WAVEPACKET13: readers_raw[i] = new LASreadItemRaw_WAVEPACKET13(); break;

                case LASitem.Type.BYTE: readers_raw[i] = new LASreadItemRaw_BYTE(items[i].size); break;

                case LASitem.Type.POINT14: readers_raw[i] = new LASreadItemRaw_POINT14(); break;

                case LASitem.Type.RGBNIR14: readers_raw[i] = new LASreadItemRaw_RGBNIR14(); break;

                default: return(false);
                }
                point_size += items[i].size;
            }

            if (dec != null)
            {
                readers_compressed = new LASreadItem[num_readers];

                // seeks with compressed data need a seek point
                for (int i = 0; i < num_readers; i++)
                {
                    switch (items[i].type)
                    {
                    case LASitem.Type.POINT10:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_POINT10_v1(dec);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_POINT10_v2(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.GPSTIME11:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_GPSTIME11_v1(dec);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_GPSTIME11_v2(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.RGB12:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_RGB12_v1(dec);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_RGB12_v2(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.WAVEPACKET13:
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_WAVEPACKET13_v1(dec);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.BYTE:
                        seek_point.extra_bytes     = new byte[items[i].size];
                        seek_point.num_extra_bytes = items[i].size;
                        if (items[i].version == 1)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_BYTE_v1(dec, items[i].size);
                        }
                        else if (items[i].version == 2)
                        {
                            readers_compressed[i] = new LASreadItemCompressed_BYTE_v2(dec, items[i].size);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    default: return(false);
                    }
                }

                if (laszip.compressor == LASzip.COMPRESSOR_POINTWISE_CHUNKED)
                {
                    if (laszip.chunk_size != 0)
                    {
                        chunk_size = laszip.chunk_size;
                    }
                    number_chunks = uint.MaxValue;
                }
            }
            return(true);
        }
Example #2
0
		// should only be called *once*
		public bool setup(uint num_items, LASitem[] items, LASzip laszip=null)
		{
			// is laszip exists then we must use its items
			if(laszip!=null)
			{
				if(num_items!=laszip.num_items) return false;
				if(items!=laszip.items) return false;
			}

			// create entropy decoder (if requested)
			dec=null;
			if(laszip!=null&&laszip.compressor!=0)
			{
				switch(laszip.coder)
				{
					case LASzip.CODER_ARITHMETIC: dec=new ArithmeticDecoder(); break;
					default: return false; // entropy decoder not supported
				}
			}

			// initizalize the readers
			readers=null;
			num_readers=num_items;

			// disable chunking
			chunk_size=uint.MaxValue;

			// always create the raw readers
			readers_raw=new LASreadItem[num_readers];
			for(int i=0; i<num_readers; i++)
			{
				switch(items[i].type)
				{
					case LASitem.Type.POINT10: readers_raw[i]=new LASreadItemRaw_POINT10(); break;
					case LASitem.Type.GPSTIME11: readers_raw[i]=new LASreadItemRaw_GPSTIME11(); break;
					case LASitem.Type.RGB12: readers_raw[i]=new LASreadItemRaw_RGB12(); break;
					case LASitem.Type.WAVEPACKET13: readers_raw[i]=new LASreadItemRaw_WAVEPACKET13(); break;
					case LASitem.Type.BYTE: readers_raw[i]=new LASreadItemRaw_BYTE(items[i].size); break;
					case LASitem.Type.POINT14: readers_raw[i]=new LASreadItemRaw_POINT14(); break;
					case LASitem.Type.RGBNIR14: readers_raw[i]=new LASreadItemRaw_RGBNIR14(); break;
					default: return false;
				}
				point_size+=items[i].size;
			}

			if(dec!=null)
			{
				readers_compressed=new LASreadItem[num_readers];

				// seeks with compressed data need a seek point
				for(int i=0; i<num_readers; i++)
				{
					switch(items[i].type)
					{
						case LASitem.Type.POINT10:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_POINT10_v1(dec);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_POINT10_v2(dec);
							else return false;
							break;
						case LASitem.Type.GPSTIME11:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_GPSTIME11_v1(dec);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_GPSTIME11_v2(dec);
							else return false;
							break;
						case LASitem.Type.RGB12:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_RGB12_v1(dec);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_RGB12_v2(dec);
							else return false;
							break;
						case LASitem.Type.WAVEPACKET13:
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_WAVEPACKET13_v1(dec);
							else return false;
							break;
						case LASitem.Type.BYTE:
							seek_point.extra_bytes=new byte[items[i].size];
							seek_point.num_extra_bytes=items[i].size;
							if(items[i].version==1) readers_compressed[i]=new LASreadItemCompressed_BYTE_v1(dec, items[i].size);
							else if(items[i].version==2) readers_compressed[i]=new LASreadItemCompressed_BYTE_v2(dec, items[i].size);
							else return false;
							break;
						default: return false;
					}
				}

				if(laszip.compressor==LASzip.COMPRESSOR_POINTWISE_CHUNKED)
				{
					if(laszip.chunk_size!=0) chunk_size=laszip.chunk_size;
					number_chunks=uint.MaxValue;
				}
			}
			return true;
		}