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 encoder (if requested)
			enc=null;
			if(laszip!=null&&laszip.compressor!=0)
			{
				switch(laszip.coder)
				{
					case LASzip.CODER_ARITHMETIC: enc=new ArithmeticEncoder(); break;
					default: return false; // entropy decoder not supported
				}
			}

			// initizalize the writers
			writers=null;
			num_writers=num_items;

			// disable chunking
			chunk_size=uint.MaxValue;

			// always create the raw writers
			writers_raw=new LASwriteItem[num_writers];

			for(uint i=0; i<num_writers; i++)
			{
				switch(items[i].type)
				{
					case LASitem.Type.POINT10: writers_raw[i]=new LASwriteItemRaw_POINT10(); break;
					case LASitem.Type.GPSTIME11: writers_raw[i]=new LASwriteItemRaw_GPSTIME11(); break;
					case LASitem.Type.RGB12: writers_raw[i]=new LASwriteItemRaw_RGB12(); break;
					case LASitem.Type.WAVEPACKET13: writers_raw[i]=new LASwriteItemRaw_WAVEPACKET13(); break;
					case LASitem.Type.BYTE: writers_raw[i]=new LASwriteItemRaw_BYTE(items[i].size); break;
					case LASitem.Type.POINT14: writers_raw[i]=new LASwriteItemRaw_POINT14(); break;
					case LASitem.Type.RGBNIR14: writers_raw[i]=new LASwriteItemRaw_RGBNIR14(); break;
					default: return false;
				}
			}

			// if needed create the compressed writers and set versions
			if(enc!=null)
			{
				writers_compressed=new LASwriteItem[num_writers];

				for(uint i=0; i<num_writers; i++)
				{
					switch(items[i].type)
					{
						case LASitem.Type.POINT10:
							if(items[i].version==1) throw new NotSupportedException("Version 1 POINT10 is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_POINT10_v2(enc);
							else return false;
							break;
						case LASitem.Type.GPSTIME11:
							if(items[i].version==1) throw new NotSupportedException("Version 1 GPSTIME11 is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_GPSTIME11_v2(enc);
							else return false;
							break;
						case LASitem.Type.RGB12:
							if(items[i].version==1) throw new NotSupportedException("Version 1 RGB12 is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_RGB12_v2(enc);
							else return false;
							break;
						case LASitem.Type.WAVEPACKET13:
							if(items[i].version==1) writers_compressed[i]=new LASwriteItemCompressed_WAVEPACKET13_v1(enc);
							else return false;
							break;
						case LASitem.Type.BYTE:
							if(items[i].version==1) throw new NotSupportedException("Version 1 BYTE is no longer supported, use version 2.");
							else if(items[i].version==2) writers_compressed[i]=new LASwriteItemCompressed_BYTE_v2(enc, 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;
					chunk_count=0;
					init_chunking=true;
				}
			}

			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 encoder (if requested)
            enc = null;
            if (laszip != null && laszip.compressor != 0)
            {
                switch (laszip.coder)
                {
                case LASzip.CODER_ARITHMETIC: enc = new ArithmeticEncoder(); break;

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

            // initizalize the writers
            writers     = null;
            num_writers = num_items;

            // disable chunking
            chunk_size = uint.MaxValue;

            // always create the raw writers
            writers_raw = new LASwriteItem[num_writers];

            for (uint i = 0; i < num_writers; i++)
            {
                switch (items[i].type)
                {
                case LASitem.Type.POINT10: writers_raw[i] = new LASwriteItemRaw_POINT10(); break;

                case LASitem.Type.GPSTIME11: writers_raw[i] = new LASwriteItemRaw_GPSTIME11(); break;

                case LASitem.Type.RGB12: writers_raw[i] = new LASwriteItemRaw_RGB12(); break;

                case LASitem.Type.WAVEPACKET13: writers_raw[i] = new LASwriteItemRaw_WAVEPACKET13(); break;

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

                case LASitem.Type.POINT14: writers_raw[i] = new LASwriteItemRaw_POINT14(); break;

                case LASitem.Type.RGBNIR14: writers_raw[i] = new LASwriteItemRaw_RGBNIR14(); break;

                default: return(false);
                }
            }

            // if needed create the compressed writers and set versions
            if (enc != null)
            {
                writers_compressed = new LASwriteItem[num_writers];

                for (uint i = 0; i < num_writers; i++)
                {
                    switch (items[i].type)
                    {
                    case LASitem.Type.POINT10:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 POINT10 is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_POINT10_v2(enc);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.GPSTIME11:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 GPSTIME11 is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_GPSTIME11_v2(enc);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

                    case LASitem.Type.RGB12:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 RGB12 is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_RGB12_v2(enc);
                        }
                        else
                        {
                            return(false);
                        }
                        break;

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

                    case LASitem.Type.BYTE:
                        if (items[i].version == 1)
                        {
                            throw new NotSupportedException("Version 1 BYTE is no longer supported, use version 2.");
                        }
                        else if (items[i].version == 2)
                        {
                            writers_compressed[i] = new LASwriteItemCompressed_BYTE_v2(enc, 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;
                    }
                    chunk_count   = 0;
                    init_chunking = true;
                }
            }

            return(true);
        }