Data Sources

Places

XML Source

Place data comes from an XML file maintained by Facilities located at http://web.mit.edu/campus-map/search-data/bldg_data.xml. It’s about 1 MB, so I recommend not opening that link in your browser.

The URL to bldg_data.xml isn’t guaranteed to stay the same, so instead of pulling it live from the campus-map Athena locker it should be included in this project’s resources and manually updated and deployed as needed.

Symfony code for getting the file from where we keep it:

$filename = $this->get('kernel')->locateResource("@MITMobileBundle/Resources/data/xml/bldg_data.xml");

Searching

Searching should happen locally on the mobile server using bldg_data.xml rather than depending on whereis.mit.edu for searches. It may need to be converted to some intermediate format if parsing and searching 1 MB of XML for each query ends up being slow or resource intensive.

Searches should find case insensitive, whole word matches (e.g. “building” but not “uilding”) in:

  • /object/bldgnum (e.g. “W20”)
  • /object/name (e.g. “Stratton”)
  • /object/category (e.g. “building”)
  • /object/contents/name (e.g. “Taqueria”)
  • /object/contents/category (e.g. “food”)

And not find matches in the XML file’s other elements.

Converting to JSON

The contents of the XML file can mostly be converted as is into JSON. The only differences are:

  1. Unescape any HTML entities, e.g. & -> &.
  2. Turn <object id="foo"> into "id": "foo".
  3. Make sure bldgnum is output as a string.
  4. Make sure lat_wgs84 and long_wgs84 are output as numbers.
  5. Make sure category and contents/*/category are output as arrays of strings.
  6. Merge all of the separate <contents> elements into a single "contents": [] array.
  7. Don’t bother including the <floorplans> or <poly> elements.
{
  "id": "object-6",
  "name": "Eastman Laboratories",
  "lat_wgs84": 42.35953993,
  "long_wgs84": -71.09045076,
  "bldgnum": "6",
  "bldgimg": "http://web.mit.edu/campus-map/objimgs/object-6.jpg",
  "category": [
    "building"
  ],
  "street": "182 Memorial Drive (Rear)",
  "mailing": "77 Massachusetts Avenue",
  "viewangle": "north side",
  "architect": "Coolidge &amp; Carlson",
  "contents": [
    {
      "name": "6-120",
      "category": [
        "room"
      ]
    },
    {
      "name": "Materials Science and Engineering, Dept. of",
      "url": "http://dmse.mit.edu/"
    },
    {
      "name": "Spectroscopy Laboratory",
      "url": "http://web.mit.edu/spectroscopy/"
    },
    {
      "name": "Science, School of",
      "url": "http://web.mit.edu/science/"
    },
    {
      "name": "Chipman Room (6-104)"
    },
    {
      "name": "Lactation Room (6-236)",
      "url": "http://hrweb.mit.edu/worklife/child-care-parenting/breastfeeding-support/lactation-rooms/campus"
    },
    {
      "name": "Lactation Room (6C-247)",
      "url": "http://hrweb.mit.edu/worklife/child-care-parenting/breastfeeding-support/lactation-rooms/campus"
    }
  ]
}