If you're posting code snippets on blogger.com I heartily recommend you check out this blog entry by Guogang Hu:
http://developertips.blogspot.com/2007/08/syntaxhighlighter-on-blogger.html
Friday, 7 November 2008
Thursday, 6 November 2008
MSBuild & Text Transforms
I had a couple of problems with MSBuild scripts today. If you're not overly familiar with MSBuild I found Brennan's Blog has a create tutorial on it (http://brennan.offwhite.net/blog/2006/11/29/msbuild-basics-1of7/).
Firstly, ItemGroups are evaluated when the script is initially run (or something along these lines) - which in retrospect seems completely obvious. This means that if you want an ItemGroup to contain items from a build output (i.e. MSIs) then you have to create the ItemGroup via the CreateItem task. Basically, the ItemGroup is evaluated when you call the CreateItem task.
An example:
The second problem I had to overcome today was that I wanted MSBuild to transform my T4 templates. I'm currently using T4 to generate my config files as per Oleg Sych's posting at http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-config-files/. This isn't really that hard to accomplish and can be done as follows:
I'm also using the MSBuild Community Tasks (http://msbuildtasks.tigris.org/) in the last sample script. This is to make sure the config files that are checked out are writable. The Attrib task can be used to easily change file attributes.
Firstly, ItemGroups are evaluated when the script is initially run (or something along these lines) - which in retrospect seems completely obvious. This means that if you want an ItemGroup to contain items from a build output (i.e. MSIs) then you have to create the ItemGroup via the CreateItem task. Basically, the ItemGroup is evaluated when you call the CreateItem task.
An example:
...
...
The second problem I had to overcome today was that I wanted MSBuild to transform my T4 templates. I'm currently using T4 to generate my config files as per Oleg Sych's posting at http://www.olegsych.com/2007/12/how-to-use-t4-to-generate-config-files/. This isn't really that hard to accomplish and can be done as follows:
C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.1\TextTransform.exe
..\Construction\
I'm also using the MSBuild Community Tasks (http://msbuildtasks.tigris.org/) in the last sample script. This is to make sure the config files that are checked out are writable. The Attrib task can be used to easily change file attributes.
Labels:
ItemGroup,
MsBuild,
T4,
Text Templating Transformation Toolkit
Saturday, 6 September 2008
C# NMEA Latitude/Longitude
I'm working on an NMEA parser and was slightly confused about extracting the latitude and longitude. Most of my confusion arises as I am too lazy to bother reading any articles in detail and continually flick between browser tabs scanning pages instead of just reading them.
Anyway, say I'm trying to extract latitude and longitude from this GPRMC line:
$GPRMC,192031.764,A,4738.0175,N,12211.1861,W,0.094321,5.28,291004,,*14
The latitude is: 4738.0175,N
The longitude is: 12211.1861,W
According to wiki (http://en.wikipedia.org/wiki/Geographic_coordinate_conversion) there are three basic forms of coordinate:
NMEA sentences contain latitude and logitude of form "2". For example, the latitude above could be written as: 47°38.0175"N (48 degrees and 38.0175 decimal minutes).
Conversion to a decimal representation of the above is fairly trivial. We divide the minutes by 60 (as there are 60 minutes in one degree) and add this value to degrees. Finally we negate the value if it is in the southern hemisphere (or negate if W for longitude). So the above latitude would be:
4738.0175 = 47 + (38.075 /60) = 47.6345833
Anyway, say I'm trying to extract latitude and longitude from this GPRMC line:
$GPRMC,192031.764,A,4738.0175,N,12211.1861,W,0.094321,5.28,291004,,*14
The latitude is: 4738.0175,N
The longitude is: 12211.1861,W
According to wiki (http://en.wikipedia.org/wiki/Geographic_coordinate_conversion) there are three basic forms of coordinate:
- Coordinate containing degrees (integer), minutes (integer), and seconds (integer, or real number) (DMS).
- Coordinate containing degrees (integer) and minutes (real number) (MinDec).
- Coordinate containing only degrees (real number) (DegDec).
NMEA sentences contain latitude and logitude of form "2". For example, the latitude above could be written as: 47°38.0175"N (48 degrees and 38.0175 decimal minutes).
Conversion to a decimal representation of the above is fairly trivial. We divide the minutes by 60 (as there are 60 minutes in one degree) and add this value to degrees. Finally we negate the value if it is in the southern hemisphere (or negate if W for longitude). So the above latitude would be:
4738.0175 = 47 + (38.075 /60) = 47.6345833
Subscribe to:
Posts (Atom)