Click here to Skip to main content
15,885,030 members
Articles / Hosted Services / Azure

GPS Runner Maps: My First Windows Azure Application

Rate me:
Please Sign up or sign in to vote.
4.90/5 (12 votes)
20 Dec 2009CPOL3 min read 55.1K   3.1K   63  
It is "cloud" Web application to display GPS tracks on Google or Bing maps
/*
  BitVectorReader c# class: Read bitvector data using primary types
  Copyright (C) 2002 Rodrigo Reyes, reyes@charabia.net
  
  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.
  
  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.
  
  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

using System;
using System.Text;
using System.Collections;

namespace GameWatch.Utils
{
    public class BitVectorReader
    {
	private BitVector m_data;
	private int m_offset;

	public BitVectorReader(BitVector v)
	{
	    m_data = v;
	    m_offset = 0;
	}

	public bool HasMoreData()
	{
	    if (m_offset < m_data.Length)
		return true;
	    return false;
	}

	public Int32 ReadInt32()
	{
	    Int32 result = 0;
	    for (int max = m_offset+32, offset = 0; (m_offset < max) && (m_offset < m_data.Length); m_offset++, offset++)
		{
		    if (m_data.Get(m_offset))
			result |= (1<<(31 - offset));
		}
	    return result;
	}


	public Int16 ReadInt16()
	{
	    int result = 0;
	    for (int max = m_offset+16, offset = 0; (m_offset < max) && (m_offset < m_data.Length); m_offset++, offset++)
		{
		    if (m_data.Get(m_offset))
			result |= (1<<(15 - offset));
		}
	    return (Int16)result;
	}


	public byte ReadByte()
	{
	    byte result = 0;
	    for (int max = m_offset+8, offset = 0; (m_offset < max) && (m_offset < m_data.Length); m_offset++, offset++)
		{
		    if (m_data.Get(m_offset))
			result |= (byte)(1<<(7 - offset));
		}
	    return result;
	}

	public String ReadAscii(int length)
	{
	    StringBuilder buffer = new StringBuilder();
	    for (int i=0; i<length; i++)
		{
		    buffer.Append((char)ReadByte());
		}
	    return buffer.ToString();
	}

    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer Forthnet
Greece Greece
Software developer and Microsoft Trainer, Athens, Greece (MCT, MCSD.net, MCSE 2003, MCDBA 2000,MCTS, MCITP, MCIPD).

Comments and Discussions