Tasmanian police scanner part 2

December 1st, 2012

Recently I’ve upgraded the RadioFeed software to V2.2 which seems to resolve some issues a few people (including myself) were having with mobile devices. Also a user Brett mentioned a lack of Glenorchy / Hobart traffic. I checked into it and the channel S23-Hobart had been locked out which I’ve now resolved so it makes for more interesting listending for anyone that hasn’t tried in a while, just go to the following URL:

http://www.peter-johnson.com.au:8000/

Windows 7 empty recycle bin “hanging” with a lot of files

October 31st, 2012

I was just cleaning up a directory path and had over 1GB and several thousand files in my recycle bin. About 5 minutes after selecting “Empty Recycle Bin” I still hadn’t even got as far as the prompt asking to confirm the delete. After some system monitoring I saw that Microsoft Security Essentials was attempting to scan the files. After temporarily disabling real-time protection the prompt immediately appeared and the bin emptied within 10 seconds or so.

Rather interesting that they scan files that are about to be deleted. The .NET FileSystemWatcher has a deleted method as does the underlying Win32 API so it’s not hard to detect.

Rasberry Pi initial configuration

July 12th, 2012

Posting my initial Raspberry Pi configuration steps to enable SSH / FTP / VNC and Wifi to a WPA2 access point in case it’s of use to anyone else getting started with the Pi. WPA connection is automatic, I’ve left VNC manually started to save resources when not in use, it can be started via SSH or the console using the following command:

vncserver :1 -geometry 1024×768 -depth 16 -pixelformat rgb565


# loaded debian6-19-04-2012.img to SD card
# expanded main partition using gparted on another machine

sudo /boot/boot_enable_ssh.rc

uname -a
# Linux raspberrypi 3.1.9+ #90 Wed Apr 18 18:23:05 BST 2012 armv6l GNU/Linux

sudo dpkg-reconfigure tzdata

sudo nano /etc/dhcp/dhclient.conf # set host-name

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install ca-certificates git-core proftpd tightvncserver

sudo wget http://goo.gl/1BOfJ -O /usr/bin/rpi-update

sudo chmod +x /usr/bin/rpi-update

sudo rpi-update # ignore error about libvchiq_arm.so

sudo reboot

uname -a
# Linux raspberrypi 3.1.9+ #159 PREEMPT Wed Jul 11 19:54:53 BST 2012 armv6l GNU/Linux

wpa_passphrase <SSID> <Passphrase> # copy hex from psk= and paste into <PSK> below

sudo nano /etc/network/interfaces
# append following to bottom:
auto wlan0
iface wlan0 inet dhcp
wpa-ssid <SSID>
wpa-psk <PSK>

Tasmanian Police Scanner

February 25th, 2011

I’ve just installed Radio Feed 1.5 on my server, a nice free piece of software for radio scanner streaming. It’s connected to a Uniden UBCD396T set to receive the Tasmanian Government EDACS radio network used by Tasmania Police. It’s set to pickup communications from Mount Wellington so only covers Southern Tasmanian. No guarantees on uptime but feel free to give it a try at:

http://www.peter-johnson.com.au:8000

Canon 7D native ISO tests

May 26th, 2010

Recently I picked up a Canon 7D which I’m really enjoying so far. While researching the camera I found various references to both 100 and 160 being the native ISO and as I do quite a bit of still photography from a tripod was keen to determine the optimum ISO setting and also the best ISO multiples to use for available light shooting. Between various forum posts there seemed to be about a 50/50 mix of people suggesting one or the other was the native ISO so I decided to do my own test. I printed an ISO 12233 test chart replica from Cornell University on an A4 piece of paper and set it up inside a lightbox in a room with no direct sunlight. I shot using the 7D with a Canon 70-200mm f/2.8L IS USM II lens at f/2.8 at around 100mm focal length, tripod mounted with a remote cable release, manually focused once at the start of the sequence with the camera set to aperture priority mode. While I’m sure there are plenty of things that could be done better I thought this was typical of the kind of lighting situation where I’d be tempted to knock up the ISO speed. I imported the RAW files in Adobe Lightroom 3 beta 2 and didn’t perform any operations other than changing the colour balance and exposure equally on all shots to lighten them up for printing.

The results? ISO 100 and 160 were very close, but I felt 160 was just a little more defined so I might settle on that for tripod shooting. I don’t have an expert eye but I couldn’t spot any nasty steps in the ISO range that other’s have reported, in my mind it was a pretty even transition with the each ISO speed. ISO 400 remained excellent so I wouldn’t hesitate to go that high for quality shots. What I’d set out to find is if automatic ISO was a useful mode and I feel that it is. From what I gather Canon don’t release specific details on the native ISO of their cameras but the results made me wonder if on a modern DSLR it’s a myth, I’d assume the ISO setting equates to a sampling period for the sensor and can’t think of any reason it couldn’t be infinitely variable over a range. Of course at the lower end of the range there could be an optimum level such as 160 below which the sensor becomes saturated and needs to be attenuated which may explain why ISO 160 appeared marginally better than ISO 100.

Geocoding using OSM data and SQL/Server 2008

January 29th, 2010

I’ve just completed importing the OpenStreetMap data into SQL/Server 2008 using the new geography data types. Originally I linked the data to Manifold GIS to verify the import process but have just started on my first real project using the data which is address geocoding for a GPS tracking site located in Australia. The OSM data doesn’t contain enough street number information to be useful for most areas but the aim is to provide nearest street names at no charge, versus some local commercial geocoding services that charge around ten cents per address.

Loading the OSM ‘ways’ as a series of around 250,000 linestrings seems to be giving a performance of around 40 geocoding operations per second. As you’d expect performance of the STDistance method depends heavily on the distance, so in the SQL/Server stored procedure I first start by locating streets within 100 meters, followed by 1Km, 10Km and finally 100Km. The series of queries only attempts to find street names not matched by the previous query, and for Australia these numbers seem to give a match rate of about 90%, 9%, 1% and not much for the final distance that results in good performance.

For optimisation of the spatial index I found that changing the default of medium for each level in the index grid to high gave approximately a 100% increase in performance. It makes sense that the finest level of granularity would work best when looking for the nearest distance to points. The following was what I ended up using for the spatial index definition, changing the cells per object didn’t seem to have a great deal of effect for this dataset / application so I left it at the default value of 16.

CREATE SPATIAL INDEX [spatial_IX] ON [dbo].[Ways] 
(
	[LineString]
) USING  GEOGRAPHY_GRID 
WITH (
    GRIDS =(LEVEL_1 = HIGH,LEVEL_2 = HIGH,LEVEL_3 = HIGH,LEVEL_4 = HIGH), 
    CELLS_PER_OBJECT = 16, PAD_INDEX  = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, 
    ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) 
ON [PRIMARY]

JScript to automatically retrieve / check web page

January 12th, 2010

Recently I discovered a problem with Manifold WMS where if the page wasn’t accessed for a while it would cause the w3wp.exe IIS worker thread to loop. Until I find out the underlying cause I’ve written the map_keepalive.wsf script below to automatically retrieve a web page and scheduled it to run every 5 minutes. I assume something gets spun down and the concurrent WMS requests cause a problem, the map_test.asp page that this script retrieves is just a default IMS page generated from within Manifold.

&lt;package&gt;
  &lt;job id=&quot;js&quot;&gt;
     &lt;script language=&quot;JScript&quot;&gt;
	var finished = false;
	var timeout = 0;
	var timeoutSecs = 30;
	var forAppending = 8;
	var xmlhttp = WScript.CreateObject(&quot;MSXML2.XMLHTTP&quot;);
	xmlhttp.open(&quot;GET&quot;, &quot;http://www.satsleuth.com&quot;, false);
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4)
			finished = true;
	}
	try {
		xmlhttp.Send(&quot;&quot;);
	} catch (e) {
	}
	while ((!finished) &amp;&amp; (timeout &lt; timeoutSecs))
	{
		timeout++;
		WScript.Sleep(1000);
	}
	var msg = &quot;&quot;
	if (!finished)
		msg = &quot;Timeout occurred&quot;;
	else if (xmlhttp.status != 200)
		msg = &quot;Error retrieving map_test.asp, error code: &quot; + xmlhttp.status;
	if (msg != &quot;&quot;) {
		var oFSO = WScript.CreateObject(&quot;Scripting.FileSystemObject&quot;);
		var oFile = oFSO.OpenTextFile(&quot;map_keepalive.log&quot;, forAppending, true);
		var dt = new Date();
		oFile.WriteLine(dt.toLocaleString() + &quot;: &quot; + msg);
		oFile.Close();
	}
      &lt;/script&gt;
   &lt;/job&gt;
&lt;/package&gt;

Using MySQL variables to limit a select query

December 18th, 2009

I discovered today when writing a stored procedure for a web reporting application that MySQL doesn’t support using variables for the LIMIT clause in a SELECT statement. I didn’t really want to write a dynamic query, one workaround that I found while Googling looked promising:

SET SQL_SELECT_LIMIT = RowLimit (can be a variable)
SELECT ….
SET SQL_SELECT_LIMIT = default

However it is applied at a global level and I needed different limits within a sequence of four queries formed into a union to get the top N results for a series of categories. Because I was giving the user the limited choice of retrieving the top 10, 20, 50 or 100 items I ending up using a CASE statement with each WHEN clause containing a duplicate of the entire query. Certainly not a pretty solution but works and is reasonably maintainable by leaving the LIMIT clause on a seperate line so any changes can be cut & pased down the procedure.

Manifold GIS IMS (Internet Map Server) error 0x80004005

December 2nd, 2009

I’m working on an iPhone 3GS mapping application using Manifold as a map tile server via the Web Map Service (WMS) protocol. I did initial development using a Vista x64 development machine on my intranet via wifi but had considerable difficulty moving to my Windows Server 2008 64-bit machine so that I could access the map tiles remotely via the 3G network. It’s been a while since I’d deployed a Manifold IMS solution but I remembered the usual steps:

  • Web site must be running under 32-bit mode because the COM object is 32-bit only
  • Map files, config.txt and any linked resources must be available to the ‘NETWORK SERVICE’ account
  • Same account needs access to Windows\serviceprofiles\networkservice\AppData\Local\Temp

    After my initial attempts failed I did numerous searches of the Manifold site and other resources and worked through the Manifold “Problems with the Internet Map Server” guide but kept getting the 80004005 error that I thought pointed at a permissions error. I thought to install the excellent SysInternals Process Monitor utility and the first error that became apparent was a file permissions error writing to the file “c:\Manifold.log”. I created a blank file with that name and granted full control permissions to the NETWORK SERVICE account used by IIS 7 and found several errors including the following:

    Invalid component name
    Incompatible component type
    Can’t generate unique name for temporary file

    Creating a new blank map file solved the problem so it appeared to be a problem within the Manifold map file itself, I decided to copy back a fresh copy of the map from my development machine so I could try removing a few elements until it worked but found it worked first go with the fresh copy. I didn’t modify anything with the map file so can only conclude it got corrupted at some initial stage while I had configuration problems. Anyway to avoid similar problems in the future I’ll make sure that during Manifold IMS deployment I always include a blank “c:\Manifold.log” file with appropriate permissions and be careful to archive any changes no matter how small they seem in source code control as a recovery point.

    I love Manifold GIS in general and it represents great value for money, but it would be nice if the object model was structured so that it would throw back a response code in the form of a text message on the call to MapServer.Create so it could be passed back to the client browser. Additionally rather than the non-standard practice of writing a text file to the root directory it would also be nice to see it write a meaningful errors to the Windows application event log.

  • Using JET OLE DB under ASP and Vista x64

    November 1st, 2009

    I’m currently performing some work on classic ASP pages that during development are retrieving data from an existing Microsoft Access database. After receiving the following error I found that Microsoft haven’t and have no plans to release JET OLE DB drivers for 64-bit platforms. Fair enough it’s hardly the way of the future but I wanted to be able to perform some development on the pages before migrating to SQL/Server.

    Provider=Microsoft.Jet.OLEDB.4.0
    ADODB.Connection error ‘800a0e7a’
    Provider cannot be found. It may not be properly installed.

    After some digging around I found the solution was to change the IIS 7 settings to run the application in 32-bit mode. That can be performed under Vista x64 using the following steps:

  • Click Start > All programs > Administrative tools > Internet Information Server (IIS) Manager
  • Under the machine name click on Application Pools.
  • Right-mouse click on DefaultAppPool and select Advanced Settings…
  • Under the general section set “Enable 32-Bit Applications” to true.
  • Press OK and IIS should now be running in 32-bit mode, no other actions are necessary.