Wednesday, December 9, 2009

How to know the location of Mobile Cell Tower


In Order to know the location of certain cell tower, you should identify this Cell Tower; Mobile Cell Towers are normally identified with certain IDs
  • MCC :: Mobile Country Code
  • MNC :: Mobile Network Code
  • LAC :: Location Area Code
  • CID :: cell Identifier
In this post, I will assume you already know the identifiers of the cell tower you want to know its location (latitude, longitude).

So far I can only find Three ways to be able to get the location of that Mobile Cell Tower

    1. Asking your Mobile Network Company about the exact location of that Tower, but they will probably not answer you and even if they did they will not give you the map of their whole towers network, "so that way suck if you want to be independent of the Mobile company"
    2. Using OpenCellID project which is very good project "just my opinion", but the project is still limited to some places in some countries, and it is not world wide like Google
    3. Being able to use Google GeoLocation-Api. After going around with this API, I was able to reverse the use of the API to be able to get the location of cell towers from it, and to use it to get the locations of around 250 towers in Alexandria Egypt
    You can see the list of Alexandria Cell Towers Networks here.

    To make my work more user friendly, i developed a simple Application called iTScan, which you supply it with the cell towers identifier and it will provide you with the location of the tower in different file formats

    Finally I want to say that I believe that OpenCellID gives you better accuracy of the location of the cell tower than Geo-Location api, i have no prove which approach is better but I think the way geo-Location api work to get location of cell towers will probably not be accurate as OpenCellID which depends on manually identify the places of the Mobile Cell Towers.

    This work have been done in 2009 and according to the way geo-location api works, every thing went fine "at that time".

    If you know any other method to know the location of cell towers, please share in your comments

    Friday, October 9, 2009

    Http Scoop Crack

    Http Scoop is a mac based Http sniffer, in my opinion it is the best considered to other alternatives because
    1. It don't require any configuration
    2. Small size "not like wireshark"
    3. Nice and simple GUI
    But of course it is not free, that why i tried to crack that 14 days trail thing. it appeared that it wasn't that much hard, not because i am a unique developer but they did have a weak defense.

    Anyway, you can download the free, crack version from here.

    Just download, unzip and run.

    If for some reason it didn't work with you, plz make a comment about it,so i try to fix that case

    Saturday, September 19, 2009

    XML parsing on different mobile platforms (J2ME, Android, iPhone)

    Before writing this post, I was thinking that there is a big difference between parsing xml in different mobile platforms (J2ME, Android, iPhone) but it appeared that they are much similar to each other.

    The following is the file that is to be parsed in that tutorial

    ---------------
    <xml>
    <data id="5</data>
    <name>Forrest</name>
    <age>25</age>
    <username>forrestgrant</username>
    </data>
    </xml>
    ------------------
    J2ME

    To be able to parse xml in J2ME you will need to add Kxml.zip to your project resource files because parsing xml in J2ME requires XmlParser which is not available in the default J2ME package.
    To start parsing XML in J2ME you created XmlParser object, give it a reader object from the string, file, URL or whatever you are trying to read from, Then you start using that parser to get something called ParseEvents which contains type, name, text.

    Type is used to know type of the current tag, the parser is handling whether it is
    Xml.START_DOCUMENT:
    Indication that parser has just started parsing the xml document.
    Xml.START_TAG
    Indicates the parser is current handling a starting tag.

    More tags and its usage can be found here.

    Name is used to get the tag name of the current node that is being parsed.
    Text is used to get the get the string value within the current node you parsing.

    Sample J2ME code
    Creating XMLParser For String

    byte[] xmlByteArray = xmlString.getBytes();
    ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlByteArray);
    InputStreamReader xmlReader = new InputStreamReader(xmlStream);
    XmlParser parser = new XmlParser(xmlReader);

    Iterating Over XML Tree

    boolean isParsing = true;
    while(isParsing)
    {
    pe = parser.read();
    switch (pe.getType())
    {
    case Xml.START_TAG:
    tagName = pe.getName();
    if(tagName.equals("data"))
    {
    Attribute id = pe.getAttribute("id");
    System.out.println("id value = "+id.getValue());
    }
    if(tagName.equals("name"))
    {
    pe = parser.read();
    tagValue = pe.getText();
    System.out.println("name value = "+tagValue);
    }
    else if(tagName.equals("age"))
    {
    pe = parser.read();
    tagValue = pe.getText();
    System.out.println("age value = "+tagValue);
    }
    else if(tagName.equals("username"))
    {
    pe = parser.read();
    tagValue = pe.getText();
    System.out.println("username value = "+tagValue);
    }
    break;
    case Xml.END_TAG:
    tagName = pe.getName();
    if(tagName.equals("data"))
    {
    isParsing = false;
    }
    break;
    }
    }
    Android

    The main difference parsing xml in J2ME and Android is the following
    1. The xml parsing library is already available in the Android SDK , so you don’t have to download anything.
    2. The navigation through the xml Tree, is done automatically, you only state your Parser handler class, all xml event are sent to that class whether it is start document , tag, end document or tag or whatever, so to be able to parser XML in Android, you first need to create You XML handler class which extends DefaultHandler class where you override the method you are going to write your handler within it.
    Sample Android Code
    Creating XMLParser For String

    SAXParserFactory spf = SAXParserFactory.newInstance();
    SAXParser sp = spf.newSAXParser();

    /* Get the XMLReader of the SAXParser we created. */
    XMLReader xr = sp.getXMLReader();
    /* Create a new ContentHandler and apply it to the XML-Reader*/
    MYXMLParser myExampleHandler = new MYXMLParser();
    xr.setContentHandler(myExampleHandler);
    byte[] xmlByteArray = xmlString.getBytes();
    ByteArrayInputStream xmlStream = new ByteArrayInputStream(xmlByteArray);
    InputStreamReader xmlReader = new InputStreamReader(xmlStream);
    xr.parse(new InputSource(xmlReader));

    My XML handler Example

    public class MYXMLParser extends DefaultHandler{
    private String textBetween;

    @Override
    public void startElement(String uri, String localName, String name,
    Attributes attributes) throws SAXException {
    if(localName.equals("data"))
    {
    String id = attributes.getValue("id");
    System.out.println("id value = "+id);
    }
    textBetween = "";
    }
    @Override
    public void characters(char ch[], int start, int length) {
    textBetween += new String(ch, start, length);
    }
    @Override
    public void endElement(String uri, String localName, String name)
    throws SAXException {
    if(localName.equals("name") ||localName.equals("age") || localName.equals("username"))
    System.out.println(localName+" value = "+textBetween);
    }
    @Override
    public void endDocument() throws SAXException {
    super.endDocument();
    }

    }

    iPhone (Objective C)

    Parsing XML in that SDK is identical to parsing XML in Android , the only difference here is that you optionally implement NSXMLParserDelegate, after identifying the delegate you will receive the events in the NSXMLParserDelegate methods like


    - (void)parserDidStartDocument:(NSXMLParser *)parser
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
    and other methods

    Creating XMLParser For String

    NSXMLParser* mParser = [[NSXMLParser alloc] initWithData:[xmlString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
    [mParser setDelegate:self];
    BOOL success = [mParser parse];

    Handling XML Events

    -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
    if([elementName isEqual:@"data"])
    {
    NSString* value = [attributeDict objectForKey:@"id"];
    NSLog([NSString stringWithFormat:@"id value = %@",value]);
    }
    }

    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
    if (!currentStringValue) {
    // currentStringValue is an NSMutableString instance variable
    currentStringValue = [[NSMutableString alloc] initWithCapacity:50];
    }
    [currentStringValue appendString:string];
    }

    - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    if([elementName isEqual:@"name"])
    {
    NSLog([NSString stringWithFormat:@"name value = %@",currentStringValue]);
    }else if([elementName isEqual:@"age"])
    {
    NSLog([NSString stringWithFormat:@"age value = %@",currentStringValue]);
    }else if([elementName isEqual:@"username"])
    {
    NSLog([NSString stringWithFormat:@"username value = %@",currentStringValue]);
    }
    [currentStringValue release];
    currentStringValue = nil;
    }



    More detailed Sample code is available to download from here

    Saturday, August 15, 2009

    Great Quotes

    From Troy modified a little bit
    • Original :: Honor you gods, Love you woman, defend your country "Achilles"
    • my version :: Honor you God, Love you women, defend your Religion,family
    • All that is necessary for the triumph of evil is that good men do nothing "Edmund Burke"
    • The price of greatness is responsibility "Winston S. Churchill"
    • I would rather live a short life of glory than a long one of obscurity "Alexander The Great"
    • Those who vote decide nothing. Those who count the vote decide everything "Joseph Stalin"
    • No one's a virgin, life screws us all! "AJ McLean"
    • Sex isn't the answer. Sex is the question, yes is the answer "AJ McLean"
    • Failure is an option, fear is not. "James Cameron"
    • No Retreat, No Surrender. "movie 300"
    • No Woman No Cry . "Bob marley"
    • Good artists copy, great artists steal "Picasso"

    Monday, August 10, 2009

    Evaluating JavaScript from Java

    To evaluate some JavaScript code in java, you have to do the following
    1. Create instance of type ScriptEngineManager
    2. Get JavaScript engine instance by called getEngineByName method
    3. Us e the eval method to evaluate your javascript code
    Sample Code

    =================================================

    ScriptEngineManager manager = new ScriptEngineManager();
    ScriptEngine engine = manager.getEngineByName("js");
    engine.eval("var x = 5;var y = x + 2");
    System.out.println(engine.eval("y"));

    =================================================

    Tuesday, July 14, 2009

    Sending HTTP GET request in Flash Lite 3.0


    To send HTTP GET request in Flash Lite you have two options depending on the type of data you are receiving

    Case you want to receive normal plain text
    Sample Code

    ===================================================

    var requestHandler:LoadVars = new LoadVars();

    requestHandler.load("http://www.google.com",requestHandler,"GET");

    requestHandler.onData = function(str:String) {
    trace("data reached");
    if (str == undefined) {
    trace("Error loading content.");
    return;
    } else
    {
    trace("can be read.");
    //testTxt is a container where text can be displayed
    testTxt.text = str;
    }
    }
    ===================================================

    N.B:
    If you tried to print the str in the output window, the str will not be printed, the only way to see that output is to set the content of a container with it.

    Case you want to receive XML data

    Sample Code

    ===================================================

    var xmlData:XML = new XML();
    xmlData.ignoreWhite = true;

    xmlData.load("http://rss.news.yahoo.com/rss/entertainment");

    xmlData.onLoad = function(sucesso:Boolean):Void {
    if (sucesso) {
    var firstlist:Array = xmlData.childNodes;
    var secondList:Array = firstlist[0].childNodes;
    //.......................
    //.......................
    //....................... so on
    }
    };

    ===================================================

    Friday, July 10, 2009

    Coordinate System Utility Library in Java

    LatLongLib is a java library that provides the basic operations to be done on difference coordinate system
    • Latitude / longitude points
    • Degree, Minute, Second points
    • UTM points
    To download LatLongLib library click here.
    To find more details about the package (Javadoc, Testing Samples), click here.

    The main Features provided by the package is
    1. Get Distance between two latitude/longitude points in meters using
      • getHaversineDistance
      • getVincentyDistance
      • getQuickEstimate
    2. Get slope between two latitude/longitude points using
      • getSlope
    3. Get point apart from certain point by certain distance and certain angle using
      • getPointAtDistance
    4. Convert latitude/longitude points to Degree Minute Second point using
      • calculateDMSFormat
    5. Convert Degree Minute Second point to latitude/longitude points using
      • calculateDDFormat
    6. Convert latitude/longitude points to UTM point using
      • LLtoUTM
    7. Convert UTM point to latitude/longitude points using
      • UTMtoLL