Datasets – Singapore Post (SP)

Singapore Post
SingPost is Singapore’s designated Public Postal Licensee (PPL), providing efficient and high quality domestic and international postal services. They are also the leading logistics provider in the domestic market and own one of the largest retail distribution networks.

Datasets Available

Dataset Description URL Metadata
PostOffice Post Offices available locations in Singapore http://api.projectnimbus.org/spodataservice.svc/PostOfficeSet Click Here
SAM SAM machines locations in Singapore http://api.projectnimbus.org/spodataservice.svc/SAMSet Click Here

Code Snippet

.NET – How do I access a complete list of Post offices near me

public List<POEntry> GetPOFromNimbusSP(string AccountKey, string UniqueUserID)
    {

        System.Net.WebRequest wr=
          HttpWebRequest.Create(
            "http://api.projectnimbus.org/spodataservice.svc/PostOfficeSet?Latitude=1.3&Longitude=103.85&Distance=2000");
        wr.Headers.Add("AccountKey",AccountKey);
        wr.Headers.Add("UniqueUserID",UniqueUserID);
        wr.Method = "GET";
        WebResponse res = wr.GetResponse();
        string resStr
         = new System.IO.StreamReader(res.GetResponseStream()).ReadToEnd();

        XNamespace atomNS
          = "http://www.w3.org/2005/Atom";
        XNamespace dNS
          = "http://schemas.microsoft.com/ado/2007/08/dataservices";
        XNamespace mNS
          = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

        List<POEntry> results
          = (from item in XElement.Parse(resStr).Descendants(atomNS + "entry")
            let post = item.Element(atomNS + "content").Element(mNS +"properties")
                select new POEntry() {
                PostOfficeID post.Element(dNS +"PostOfficeID").Value,
                Name = post.Element(dNS +"Name").Value,
                Lat = post.Element(dNS + "Latitude").Value,
                Lon = post.Element(dNS + "Longitude").Value
            }).ToList();

        return results;
    }

Java – How do I access a complete list of Post Offices near me

public ArrayList<PostOffice> getPostOfficeNearMe(String accountKey, String uniqueId) {
  poList = new ArrayList<PostOffice>();
  try {
    URL _url = new URL("http://api.projectnimbus.org/spodataservice.svc/PostOfficeSet?Latitude=1.3&Longitude=103.85&Distance=2000");
    URLConnection _urlConn = _url.openConnection();
    _urlConn.setRequestProperty("accept", "*/*");
    _urlConn.addRequestProperty("AccountKey", accountKey);
    _urlConn.addRequestProperty("UniqueUserID", uniqueId);
    BufferedReader br = new BufferedReader(new InputStreamReader(_urlConn.getInputStream()));
    String line = null;
    StringBuilder strBuilder = new StringBuilder();
    while ((line = br.readLine()) != null) {
      strBuilder.append(line);
      System.out.println(line);
    }
}

String[] IProperties = strBuilder.toString().split("<m:properties>");
    for (String str : IProperties) {
      PostOffice postOff = new PostOffice();
      postOff.setPostOfficeID(Utils.getStringBetween(str, "<d:PostOfficeID m:type=\"Edm.Int32\">", "</d:PostOfficeID>"));
      postOff.setName(Utils.getStringBetween(str, "<d:Name>", "</d:Name>"));
      postOff.setLatitude(Utils.getStringBetween(str, "<d:Latitude m:type=\"Edm.Int32\">", "</d:Latitude>"));
      postOff.setLongitude(Utils.getStringBetween(str, "<d:Longitude m:type=\"Edm.Int32\">", "</d:Longitude>"));
      poList.add(postOff);
      }
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return poList;
}

Helpers Available

.NET – C# Proxy Classes: click here | Read this blog post for more information to use these proxy classes.

JAVA – Read this blog post for more information to use JAVA to connect to the data service.

PHP & AJAX – Read this blog post for more information to use PHP/AJAX to connect to the data service.

obj C / xcode – coming soon

Terms of Use

The datasets:

  • Are here as a community technology preview for a period of time (TBD).
  • Cannot be used in any public offering.
  • Are offered as-is with no official support.

Support

None at this time.

This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Datasets – Singapore Post (SP)

  1. Pingback: What is Project Nimbus? How do I get started? « Project Nimbus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s