Thursday, July 21, 2011

SmartClient and Jersey/JAX-RS

Here's a good tutorial on using jax-rs to return smartclient compatible data sources.

Thursday, July 14, 2011

Fun with DC's gis data, part 1

It looks like DC has kindly released quite a bit of gis data for public consumption. One of the more interesting sets is the regularly updated Owner Polygon dataset available from data.dc.gov. This is a shapefile containing current property records for everything in the District. Unfortunately, it's not available kml for easy display in google's tools. However the 70MB esri shapefile is available. Using Open Layers, PostGIS, and and GeoServer, we can get start displaying everything, but what if we want to use google maps and do things the hard way? To solve that, there's a few simple steps to allow polygon querying, selection, and display on google maps.
  1. Import data into PostGIS
  2. Create GIS servlet
  3. Draw the data on google maps
  4. Query PostGIS for google's lat/long
  5. Select Properties from the map
We're going to work on step one today, import your data into PostGIS.
Prepare PostGIS
I'm running Ubuntu 11.04, PostgreSQL 8.4 with postGIS 1.5.1 installed from the default software repo.
  1. PostGIS 1.5 manual
  2. nad 83, maryland projection
psql (8.4.8)
Type "help" for help.

postgres=# create database propertymap;
CREATE DATABASE
postgres=# \q
~$ createlang plpgsql propertymap;
~$ cd /usr/share/postgresql/8.4/contrib/postgis-1.5/
postgis-1.5$ psql -f postgis.sql propertymap
postgis-1.5$ psql -f ../postgis_comments.sql propertymap;
postgis-1.5$ psql -f spatial_ref_sys.sql propertymap;
Convert Shapefile
Create a ton of insert statements using shp2pgsql:
poly$ shp2pgsql -s 926985 OwnerPly.shp ownertable > inserts.sql
Shapefile type: Polygon
Postgis type: MULTIPOLYGON[2]
If we look at the .prj file included, we see that the projection for the data is NAD_1983_StatePlane_Maryland_FIPS_1900. We need to add the projection from spatialreference.org in to our database
propertymap=# INSERT into spatial_ref_sys (srid, auth_name, .......66666666],UNIT["Meter",1.0]]');
INSERT 0 1
propertymap=# \i inserts.sql
Run your first query
propertymap=# select ownername,square,lot,premiseadd from ownertable where premiseadd like '%1600 PENNSYLVANIA%';
        ownername         | square | lot  |       premiseadd        
--------------------------+--------+------+-------------------------
 UNITED STATES OF AMERICA | 0187   | 0800 | 1600 PENNSYLVANIA AV NW
 UNITED STATES OF AMERICA | 0187   | 0802 | 1600 PENNSYLVANIA AV NW
 UNITED STATES OF AMERICA | 0187   | 0801 | 1600 PENNSYLVANIA AV NW
First, a little background on what we asked for. DC property records are based on square, suffix, and lot. Square generally refers to a city block and goes all the way back to the original city planning in the old part of the city. Lot is a lot within a square/suffix. For the most part, you can ignore suffix as it's rarely used. Next time, create a simple servlet to expose all of this.

Monday, July 11, 2011

Isolating Big Blue Button Video

This is a quick how to on manually connecting to a BBB video stream. Before we begin, here's a very, very quick background.
  • Video streams are grouped under a conference-room specific url that has for format rtmp://host/video/roomID
  • Each streaming component under BBB is available as a separate stream (ie, video, desktop, sip/audio, etc)
  • BBB uses red5 under the hood to manage these streams
  • Grab flowplayer here and the flowplayer rtmp client here
  1. Connect to your room and start your webcam.
  2. Tail /usr/share/red5/log/bigbluebutton.log and uou should see the following log lines:
    2011-07-11 18:14:54,871 [NioProcessor-1] DEBUG o.b.c.s.p.ParticipantsEventRecorder - A participant's status has changed 141 streamName 640x480141
    2011-07-11 18:14:54,919 [NioProcessor-1] DEBUG o.b.c.s.p.ParticipantsService - Setting participant status ec0449a0-b5d1-4ca5-bfdf-d118d8bc2299 141 hasStream true
    • ec0449a0-b5d1-4ca5-bfdf-d118d8bc2299 or similar is the room id
    • 640x480141 is the stream id you need
  3. Download and place flowplayer-...swf, flowplayer.rtmp-...swf, and flowplayer-...min.js into a directory.
  4. Create a web page as follows:
  5. <meta equiv="content-type" content="text/html; charset=UTF-8">
           <script type="text/javascript" src="flowplayer-3.2.6.min.js"></script>
           <title>Minimal Flowplayer setup</title>
    
    
    <div id="player"></div>
    
    <script language="javascript">
    $f("player", "flowplayer-3.2.7.swf",
    {
    clip: {
            url: '640x480141',
            live: true,
            autoBuffering: false,
            bufferLength: 1,
            provider: 'rtmp'
          },
    
           plugins: {
    
                   // here is our rtpm plugin configuration
                   rtmp: {
                           url: 'flowplayer.rtmp-3.2.3.swf',
                           netConnectionUrl: 'rtmp://your_server/video/ec0449a0-b5d1-4ca5-bfdf-d118d8bc2299'
                   }
           }
    });
    </script>
    
  6. Load up your web page and you should see the streaming video.