<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>The Inner Product</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/alan_ludwig/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:13:14 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Map Projections</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/map-projections</link>
      <pubDate>Fri, 27 May 2011 22:43:37 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2011/05/27/map-projections/</guid>
      <description><![CDATA[When displaying geospatial data you’ve got some decisions to make about what map projection to...]]></description>
      <content:encoded><![CDATA[<p>When displaying geospatial data you’ve got some decisions to make about what map projection to use.&#160; One way to look at it is this: the world isn’t flat.&#160; I know that isn’t news in the 21’st century, but that does turn out to be the problem.&#160; The world isn’t flat, but the map is.&#160; There is a lot of very interesting mathematics here.&#160; The thing to notice is that while the earth isn’t flat, it isn’t exactly three dimensional either.&#160; The surface of the earth is still two dimensional, but instead of being a a two dimensional plane, it is the surface of a sphere.&#160; The word used to describe these two dimensional spaces is <a href="https://en.wikipedia.org/wiki/Manifold">manifolds</a>. Really the first place you run into this study is multi-variable calculus which is in the 2nd year of College Calculus.&#160; </p>  <p>A map projection is simply a function that maps the points on the surface of the sphere to points in the plane.&#160; The simplest possible projection is called the cylindrical projection.&#160; You simply take the longitude and latitude and that becomes your X and Y coordinates.&#160; It is called the cylindrical projection because geometrically, it is equivalent to wrapping the map around the globe to form a cylinder with the height of the cylinder being the height of the globe.&#160; If you drew a line between the poles in the globe and then projected a ray at a normal from the line through the surface of the sphere and mapped that point to the point on the cylinder that the ray touched you’d get exactly the <a href="https://en.wikipedia.org/wiki/Cylindrical_projection#Cylindrical">cylindrical</a> projection. </p>  <p>Of course, there are infinitely many map projections.&#160; All they need to do is map every point exactly once on the sphere to a point in the plane and you can draw a map.&#160; But not all projections are created equal.&#160; It turns out that there is no such thing as the perfect projection.&#160; When you try to draw a large portion of the globe on a nice flat piece of paper there must be some distortion.&#160; You can’t take a balloon, cut along one side, and lay it flat without stretching it in one way or another. And so instead a projection is chosen to have the features that you want with the resulting distortion being something you can live with.</p>  <p>One popular projection is the <a href="https://en.wikipedia.org/wiki/Mercator_projection">Mercator Projection</a>. The Mercator projection preserves angles at the cost of distorting area. The Mercator projection also distorts the geodesic (the path that lies on the shortest distance between two points)&#160;&#160; The Mercator projection is a sort of cylindrical projection, but the projection is stretched in the Y direction.&#160; The map is stretched more&#160; and more as you get closer to the poles.&#160; This stretching gets so severe at the top and bottom of the map that the projection is largely useless north and south of 70 degrees.</p>  <p>Another interesting projection is the Scalar Projection.&#160; This projection preserves area, at the cost of distorting angles.&#160;&#160; A cylindrical projection distorts things more as they get towards the poles, just like the Mercator projection. In order to offset this distortion the map is contracted left-to-right more at the top and the bottom.&#160; While the shapes may be distorted, the areas of the shapes are preserved.</p>  <p>Just so this post isn’t completely without a little code, I’ve coded up the Mercator and Sinusoidal projections in a little class below.</p>  <p>&#160;&#160;&#160; <font face="Courier New">// This code is provided AS-IS it implies no warrinties and conferres no rights     <br />&#160;&#160;&#160; class MapProjection      <br />&#160;&#160;&#160; {</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; static public Double DegToRad(Double degrees)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return degrees * Math.PI / 180;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; static public Double RadToDeg(Double radians)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return radians * 180 / Math.PI;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; static public System.Windows.Point Mercator(Double baseLongitude, Double longitude, Double latitude)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Windows.Point point = new System.Windows.Point();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; point.X = longitude - baseLongitude;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Double phi = DegToRad(latitude);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; point.Y = RadToDeg(Math.Log(Math.Tan(Math.PI / 4 + phi / 2)));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //point.Y = RadToDeg((Math.Log((1 + Math.Sin(phi))/(1 - Math.Sin(phi)))/2);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //point.Y = RadToDeg(Math.Log(Math.Tan(phi) + 1 / Math.Cos(phi)));</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return point;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160; static public System.Windows.Point Sinusodal(Double baseLongitude, Double longitude, Double latitude)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Windows.Point point = new System.Windows.Point();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Double phi = DegToRad(latitude);      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; point.X = RadToDeg((DegToRad(longitude) - DegToRad(baseLongitude)) * Math.Cos(phi));      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; point.Y = latitude;</font></p>  <p><font face="Courier New">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return point;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</font></p>  <p><font face="Courier New">&#160;&#160;&#160; }</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Transforming Map Data for Display</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/transforming-map-data-for-display</link>
      <pubDate>Thu, 26 May 2011 20:44:19 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2011/05/26/transforming-map-data-for-display/</guid>
      <description><![CDATA[Now that we’ve got some map data it would be great to actually display it.&#160; But that still...]]></description>
      <content:encoded><![CDATA[<p>Now that we’ve got some map data it would be great to actually display it.&#160; But that still isn’t an easy job.&#160; The problem is that we’ve got two wildly different coordinate systems.&#160; For the map data, we’ve got degrees latitude and degrees longitude and for our display surface we’ve got window coordinates with the origin at the top left with positive Y going down and positive X going right.&#160; If we were simply to draw the map data directly into the window we wouldn’t even see the map. The longitude coordinates are all negative and the entire map would be off the screen.&#160; Next, the Y coordinates go in entirely the wrong direction and the map would be upside down.&#160; Finally, the map may not even fit in the window.&#160; It may be to small to see the details, or it may not fit.&#160; </p>  <p>In order to display the data we need massage the data some.&#160; We need to shift and flip the map and we need to zoom in or out enough to be able to see it. It turns out that these are all what are known as <a href="https://en.wikipedia.org/wiki/Linear_transformation">linear transformations</a>.&#160; The math here is called linear algebra.&#160; And each of these transformations can be accomplished by matrix multiplication.&#160; Each transformation is represented by a matrix and you can multiply the vector by the transformation matrix and you get back the resulting vector.</p>  <p>Believe it or not, this is such a common operation in 2D drawing that there is already full support for this in C#.&#160; You don’t really have to understand anything about matrices, how to build them, or how do to the multiplication.&#160; You can build up your transformation matrix by using the&#160; System.Media.Matrix class.&#160; You can create a translation and scaling matrix simply by using the Translate and Scale methods. And if the data you need to transform is already and array of points, then you can apply the transformation by using the Transform method.&#160; Imagine something like this:</p>  <p><font face="Courier New">// Do our transformations     <br />Matrix scale = new Matrix();      <br />scale.ScaleAt(4, -4, (minPoint.X + maxPoint.X) / 2, (minPoint.Y + maxPoint.Y) / 2);</font></p>  <p><font face="Courier New">minPoint = scale.Transform(minPoint);     <br />maxPoint = scale.Transform(maxPoint);</font></p>  <p><font face="Courier New">Matrix translate = new Matrix();     <br />translate.Translate(-minPoint.X, -maxPoint.Y);</font></p>  <p><font face="Courier New">minPoint = translate.Transform(minPoint);     <br />maxPoint = translate.Transform(maxPoint);</font></p>  <p><font face="Courier New">for (Int32 index = 0; index &lt; count; index++)     <br />{      <br />&#160;&#160;&#160; record = (PolygonRecord)shapeFileFactory.Shapes[index];      <br />&#160;&#160;&#160; // We're going to display a projection, so we need to get the projected&#160; <br />&#160;&#160;&#160; // bounding box.&#160; We'll do that by projecting the extreme points and&#160; <br />&#160;&#160;&#160; // using the result as the new bounding box.&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; // Now build an array of points that have been projected with the Mercator projection      <br />&#160;&#160;&#160; System.Windows.Point[] points = new System.Windows.Point[record.NumPoints];      <br />&#160;&#160;&#160; for (Int32 index2 = 0; index2 &lt; record.NumPoints; index2++)      <br />&#160;&#160;&#160; {      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; points[index2] = MapProjection.Sinusodal(0, record.Points[index2].X, record.Points[index2].Y);      <br />&#160;&#160;&#160; }</font></p>  <p><font face="Courier New">&#160;&#160;&#160; // Do our transformations     <br />&#160;&#160;&#160; scale.Transform(points);      <br />&#160;&#160;&#160; translate.Transform(points);</font></p>  <p><font face="Courier New">}</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Getting geospatial data from shapefiles #2</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/getting-geospatial-data-from-shapefiles-2</link>
      <pubDate>Wed, 25 May 2011 10:02:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2011/05/25/getting-geospatial-data-from-shapefiles-2/</guid>
      <description><![CDATA[In my last post we were able to read the header.&nbsp; This time, we&rsquo;ll actually drill in and...]]></description>
      <content:encoded><![CDATA[<p>In my last post we were able to read the header.&nbsp; This time, we&rsquo;ll actually drill in and get some actual map data.&nbsp; To start reading the individual records in the file we&rsquo;ll need some more data structures. All of the shape records in the spec appear to have this form:</p>
<p>&nbsp;&nbsp; <span style="font-family: Courier New;">&nbsp;&nbsp; // Copyright Microsoft Corp. All rights reserved. <br />&nbsp;&nbsp;&nbsp; // This code is provided AS-IS implies no warranties and confreres no rights <br />&nbsp;&nbsp;&nbsp; class ShapeRecord <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 RecordNumber { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 ContentLength { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ShapeType Shape { get; set; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static ShapeRecord FromBinaryReader(BinaryReader reader) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShapeRecord Record = new ShapeRecord();</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Record.RecordNumber = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Record.ContentLength = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Record.Shape = (ShapeType)reader.ReadInt32();</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Record; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</span></p>
<p>So, we can safely read this data in for each record, and then based on the shape type, we can read the rest of the record.&nbsp; In the case of the state boundary map that we are working with (<a href="https://dds.cr.usgs.gov/pub/data/nationalatlas/statesp020.tar.gz">statesp020.tar.gz</a>.), all the shapes are polygons, and so we can limit our discussion to those.&nbsp; </p>
<p>I&rsquo;ve chosen to have a separate data structure for the bounding box and the point.&nbsp; So we&rsquo;ll need those structures first:</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: Courier New;">// Copyright Microsoft Corp. All rights reserved. <br />&nbsp;&nbsp;&nbsp; // This code is provided AS-IS implies no warranties and confreres no rights <br />&nbsp;&nbsp;&nbsp; struct Point <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double X { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double Y { get; set; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Point(Double x, Double y) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : this() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.X = x; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Y = y; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Point(System.Windows.Point point) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : this() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.X = point.X; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.Y = point.Y; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public System.Windows.Point ToPoint() <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new System.Windows.Point(this.X, this.Y); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static Point FromBinaryReader(BinaryReader reader) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Point point = new Point();</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point.X = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; point.Y = reader.ReadDouble();</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return point; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static explicit operator Point(System.Windows.Point point) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Point myPoint = new Point(point); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return myPoint; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp; struct BoundingBox <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double XMin { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double YMin { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double XMax { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double YMax { get; set; }</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static BoundingBox FromBinaryReader(BinaryReader reader) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BoundingBox box = new BoundingBox();</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; box.XMin = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; box.YMin = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; box.XMax = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; box.YMax = reader.ReadDouble();</span></p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return box; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</span></p>
<p>Now that we&rsquo;ve got the structures to hold the polygon records, we just need to read them in.&nbsp; Here&rsquo;s a snippet that will do nicely:</p>
<p><span style="font-family: Courier New;">&nbsp;&nbsp;&nbsp; // Copyright Microsoft Corp. All rights reserved. <br />&nbsp;&nbsp;&nbsp; // This code is provided AS-IS implies no warranties and confreres no rights <br />&nbsp;&nbsp;&nbsp; shapes = new List&lt;ShapeRecord&gt;(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; try <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (true) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ShapeRecord record; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; record = ShapeRecord.FromBinaryReader(reader); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; catch( System.IO.EndOfStreamException ) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; switch (record.Shape) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ShapeType.Polygon: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PolygonRecord shape = PolygonRecord.FromBinaryReader(record, reader); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shapes.Add(shape); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default: <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw new InvalidDataException("Shape Type Not Recognized"); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; finally <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (file != null) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file.Close(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</span></p>
<p>We&rsquo;ve got the preliminaries out of the way now. We&rsquo;ve got a nice map file to work with and tens of thousands of geospatial points.&nbsp; From here we can have lots of fun.&nbsp;&nbsp; In the future you can expect posts on displaying geospatial data, map projections, 2D transformations.&nbsp; This is going to be a hoot!</p>]]></content:encoded>
    </item>
    <item>
      <title>Getting geospatial data from shapefiles</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/getting-geospatial-data-from-shapefiles</link>
      <pubDate>Tue, 24 May 2011 12:27:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2011/05/24/getting-geospatial-data-from-shapefiles/</guid>
      <description><![CDATA[There are lots of digital map files available from the Government.&nbsp; And in the case of the...]]></description>
      <content:encoded><![CDATA[<p>There are lots of digital map files available from the Government.&nbsp; And in the case of <a href="https://nationalatlas.gov">the national atlas</a> the data is stored in shape files.&nbsp; And, as luck with have it, shape files are easy to read. The <a href="https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf" title="ESRI Shapefile Technical Description">ESRI Shapefile Technical Description</a> is easy to find and download.&nbsp;&nbsp; The shapefile I&rsquo;m using is <a href="https://dds.cr.usgs.gov/pub/data/nationalatlas/statesp020.tar.gz" title="statesp020.tar.gz">statesp020.tar.gz</a>.&nbsp; You&rsquo;ll need something that can open a GZip file.&nbsp; Inside you&rsquo;ll find the shapefile. </p>
<p>I should also add here that while I am a professional developer, I&rsquo;m certainly not a professional C# developer.&nbsp; I live firmly in the world of C++, and not even modern C++.&nbsp; My code has been described to me as &ldquo;C with classes&rdquo;.&nbsp; But for jobs like this C# is a great too, and through little projects like this I&rsquo;m trying to make myself more familiar with it. </p>
<p>The code follows fairly easily from the spec.&nbsp; But there are a few interesting twists. One of them is the need to read bigendian integers.&nbsp; With C++, this kind of conversion is very straightforward.&nbsp; I can just do my typical type-unsafe cast and get at the raw memory and swap some bytes around. C# doesn&rsquo;t really allow the same access.&nbsp; Through a little searching I found the BitConverter class which lets me accomplish the same task.&nbsp; It doesn&rsquo;t let me do it in-place, but it works well enough.&nbsp; </p>
<p>The C# code snippet below will do the job of reading the main file header of the shapefile.&nbsp; In future posts I&rsquo;ll look at reading the actual map data out of the file and perhaps we&rsquo;ll even display it. </p>
<p>// Copyright Microsoft Corp. All rights reserved. <br />// This code is provided AS-IS implies no warranties and confers no rights</p>
<p>using System; <br />using System.IO;</p>
<p>namespace AlsShapeReader <br />{ <br />&nbsp;&nbsp;&nbsp; // Shape type codes <br />&nbsp;&nbsp;&nbsp; enum ShapeType <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NullShape = 0, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Point = 1, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PolyLine = 3, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Polygon = 5, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MultiPoint = 8, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PointZ = 11, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PolyLineZ = 13, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PolygonZ = 15, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MultiPointZ = 18, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PointM = 21, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PolyLineM = 23, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PolygonM = 25, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MultiPointM = 28, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MultiPatch = 31 <br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; // A utility class to help read bigendian integers. <br />&nbsp;&nbsp;&nbsp; static class BinaryUtilities <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Given two bytes, this routine will swap them. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void SwapBytes(ref Byte first, ref Byte second) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Byte temp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp = first; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; first = second; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; second = temp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Reverses the byte order in a 32bit integer <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static Int32 ReverseBytes(Int32 value) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Int32 returnValue; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; byte[] bytes = BitConverter.GetBytes(value);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SwapBytes(ref bytes[0], ref bytes[3]); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SwapBytes(ref bytes[1], ref bytes[2]);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; returnValue = BitConverter.ToInt32(bytes, 0);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return returnValue; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; // Class to hold the data from the main file header of a shape file <br />&nbsp;&nbsp;&nbsp; class MainFileHeader <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 FileCode { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Unused1 { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Unused2 { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Unused3 { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Unused4 { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Unused5 { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 FileLength { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Int32 Version { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public ShapeType Shape { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double XMin { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double YMin { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double XMax { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double YMax { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double ZMin { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double ZMax { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double MMin { get; set; } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public Double MMax { get; set; }</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Utility routine to populate the data from a Binary Reader <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public static MainFileHeader FromBinaryReader(BinaryReader reader) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MainFileHeader Header = new MainFileHeader();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.FileCode = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Unused1 = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Unused2 = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Unused3 = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Unused4 = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Unused5 = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.FileLength = BinaryUtilities.ReverseBytes(reader.ReadInt32()); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Version = reader.ReadInt32(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.Shape = (ShapeType)reader.ReadInt32(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.XMin = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.YMin = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.XMax = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.YMax = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.ZMin = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.ZMax = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.MMin = reader.ReadDouble(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header.MMax = reader.ReadDouble();</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return Header; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp;&nbsp; class Program <br />&nbsp;&nbsp;&nbsp; {</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void Main(string[] args) <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BinaryReader reader; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FileStream file; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MainFileHeader header; </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String fileName = @"C:\Users\alanlu\Downloads\New Folder\statesp020.shp"; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; file = File.Open(fileName, FileMode.Open); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader = new BinaryReader(file); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; header = MainFileHeader.FromBinaryReader(reader); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } <br />&nbsp;&nbsp;&nbsp; } <br />} </p>]]></content:encoded>
    </item>
    <item>
      <title>Blogging Again</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/blogging-again</link>
      <pubDate>Mon, 23 May 2011 20:32:59 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2011/05/23/blogging-again/</guid>
      <description><![CDATA[It’s been more than 5 years since I wrote something in my blog. But it is about time to get back to...]]></description>
      <content:encoded><![CDATA[<p>It’s been more than 5 years since I wrote something in my blog. But it is about time to get back to it.&#160; One of the things I’ve been playing with off and on in my spare time is location data.&#160; This has been a long time interest.&#160; As a matter of fact before I worked on WMC I actually wrote a driver for a Garmin GPS that exposed the GPS as a Windows Portable Device. It was a cool.&#160; I actually got to demo the work to our corporate VP.&#160; The project didn’t turn into anything. But because I did a few interesting white papers I did get called now and then from various teams as they developed the various GPS and Location API’s.&#160; I’m sorry to say that I didn’t actually work on any of those projects.&#160; But perhaps someday I will. </p>  <p>One of the things that I’ve discovered is that the government is a huge source of free location data.&#160;&#160; And much of that location data is available in binary form for free.&#160; On of my recent finds is <a href="https://nationalatlas.gov">https://nationalatlas.gov</a>.&#160; There are dozens of map layers available and they are all available in binary form.&#160; For example here is the location to download the digital <a href="https://nationalatlas.gov/atlasftp.html#statesp">map of the us states</a>.&#160; I’ve written a simple viewer for this data that might make for some interesting blog posts.&#160; So, stay tuned and over the course of time I’ll share what I found and some of the toys that I’ve written </p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Media Connect doesn’t share my files from a network share</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/windows-media-connect-doesnt-share-my-files-from-a-network-share</link>
      <pubDate>Thu, 02 Feb 2006 09:51:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2006/02/02/windows-media-connect-doesnt-share-my-files-from-a-network-share/</guid>
      <description><![CDATA[So, all of the issues from the previous post apply here.&nbsp; The file must be the right type, have...]]></description>
      <content:encoded><![CDATA[<p>So, all of the issues from the previous post apply here.&nbsp; The file must be the right type, have the right permissions, and be parsed.&nbsp; However, there are a couple of different things to consider that are unique to network shares.&nbsp; </p>
<p>There are a couple of ways that you can get access to data on the network in Windows.&nbsp; Two of the most popular are “mapping a network drive” and “UNC Shares”.&nbsp; WMC only supports UNC Shares.&nbsp; These are share names of the form <a href="file://alanlu02/media">\\alanlu02\media</a> for example.&nbsp; If you go into the WMC UI and attempt to share out content on a network drive then WMC will attempt to figure out the equivalent UNC path and share that instead.</p>
<p>The big problem that comes in to play with network shares are all permission related. You have to grant the right permissions. The easiest case is for a Windows XP box that is not domain joined. In this case, you must set the file and share permissions to be READ for the NETWORK account.&nbsp; That’s great, but what about files that are on a version of Windows Server?&nbsp; I got the full scoop from Mukul, who worked with me on WMC.&nbsp; Among other things he wrote the file scanner and added the network share support.&nbsp; Here is what he shared:</p>
<p>If:</p>
<ol>
<li>Your media is in a share on a W2K computer in a workgroup (for example: <a href="file://W2KServerName/FooShare">\\W2KServerName\FooShare</a>) and 
</li><li>You want to access this media on your devices using WMCv2.0 running on a WinXP machine in workgroup</li></ol>
<p>Continue reading below about the permissions requirements for W2K machine:</p>
<ol>
<li>ADD READ permission for "NETWORK" account in the W2K share permissions 
<blockquote dir=ltr style="MARGIN-RIGHT: 0px">
<p>For example: On W2K machine, If you are sharing C:\Foo as "FooShare", then open properties of C:\Foo, go to "Sharing" tab on properties windows. It will show you the information about "FooShare". Click "Permissions" button there (which is used to set permissions of this share) and add READ permission for NETWORK account</p></blockquote>
</li><li>ADD READ permission for "NETWORK" account in the security permissions of underlying folder (folder that is being shared).&nbsp; 
<blockquote dir=ltr style="MARGIN-RIGHT: 0px">
<p dir=ltr style="MARGIN-RIGHT: 0px">For example: On W2K machine, if you are sharing C:\Foo as "FooShare", then add READ permission for NETWORK account in the Properties-&gt;”Security” of folder C:\Foo.</p></blockquote>
</li><li>Enable guest account on your W2K machine (it is disabled by default on W2K machines). See this link for information on it (<a href="https://support.microsoft.com/default.aspx?scid=kb;en-us;258938">https://support.microsoft.com/default.aspx?scid=kb;en-us;258938</a>) 
<blockquote dir=ltr style="MARGIN-RIGHT: 0px">
<p>In general, WMCv2.0 should be able to access contents on W2K share after the steps given above. </p></blockquote>
</li><li>If it is still not working, try one more step. Some W2K machines have ANONYMOUS sessions explicitly disabled on them. To allow anonymous access on these shares, see this link: <a href="https://support.microsoft.com/default.aspx?scid=kb;en-us;289655">https://support.microsoft.com/default.aspx?scid=kb;en-us;289655</a> </li></ol>]]></content:encoded>
    </item>
    <item>
      <title>Windows Media Connect can’t see my files</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/windows-media-connect-cant-see-my-files</link>
      <pubDate>Wed, 01 Feb 2006 11:42:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2006/02/01/windows-media-connect-cant-see-my-files/</guid>
      <description><![CDATA[I’ll cover the common causes for Windows Media Connect (WMC) not exposing a file.&nbsp; I’m going to...]]></description>
      <content:encoded><![CDATA[<p>I’ll cover the common causes for Windows Media Connect (WMC) not exposing a file.&nbsp; I’m going to limit the information today to files that are on the same computer as WMC.&nbsp; I’ll cover network shares in another post.</p>
<p>&nbsp;There are three common reasons why WMC won’t expose a file.</p>
<ol>
<li>&nbsp;The file format isn’t supported</li>
<li>The file permissions don’t allow WMC to read the file</li>
<li>The file can’t be parsed by WMC (file is corrupt or has unrecognized content)</li></ol>
<p>Let’s take these in order.</p>
<p>WMC supports files with the following extensions (the official list is here <a href="https://www.microsoft.com/windows/windowsmedia/devices/wmconnect/faq.aspx#5_1">https://www.microsoft.com/windows/windowsmedia/devices/wmconnect/faq.aspx#5_1</a>).</p>
<p><u>&nbsp;Audio</u></p>
<ul>
<li>Windows Media Audio (.wma)</li>
<li>Advanced Systems Format (.asf)</li>
<li>MP3 (.mp3)</li>
<li>WAV (.wav)</li></ul>
<p><u>Video</u></p>
<ul>
<li>Windows Media Video (.wmv)</li>
<li>Microsoft Recorded TV Show (.dvr-ms)</li>
<li>Audio Video Interleaved (.avi)</li>
<li>MPEG-1 (.mpeg, .mpg)</li>
<li>MPEG-2 (.mp2, .mpeg, .mpg)</li></ul>
<p><u>Picture</u></p>
<ul>
<li>Bitmap (.bmp)</li>
<li>Graphics Interchange Format (.gif)</li>
<li>Joint Photographic Experts Group (.jpeg, .jpg)</li>
<li>Portable Network Graphics (.png)</li>
<li>Tagged Image File Format (.tif, .tiff)</li></ul>
<p><u>Playlists</u></p>
<ul>
<li>Windows Media Playlist (.wpl)</li>
<li>MP3 Playlist (.m3u)</li></ul>
<p>If your media file isn’t in one of the above formats, then you’ll need to convert it to one of the above formats if you’d like to use WMC to play it back.&nbsp; The two file formats that I hear about most often that aren’t supported are .MP4 and whatever the iTunes format is (I honestly can’t remember what the extension is).</p>
<p>The next most common problem is file permissions.&nbsp; In order to share a local file the file must have read permissions granted to NETWORK SERVICE.&nbsp; You can check permissions on a particular file using the cacls.exe program from the command line or you can do it in explorer.&nbsp; Detailed instructions on how to fix file permission errors from explorer are found here <a href="https://www.microsoft.com/windows/windowsmedia/devices/wmconnect/faq.aspx#4_5">https://www.microsoft.com/windows/windowsmedia/devices/wmconnect/faq.aspx#4_5</a>.</p>
<p>The last problem that is commonly encountered are file parsing problems.&nbsp; For some reason WMC hits an error when trying to read the file.&nbsp; If WMC can’t parse the file it doesn’t share the file.&nbsp; There are a couple of ways to attach this problem.&nbsp; First, if the file doesn’t play in windows media player it probably won’t play in WMC either.&nbsp; Try that first.&nbsp; If that works then it is still possible that the file can’t be parsed by WMC.&nbsp; You should check the file-scanning log that is usually found at this path: </p>
<blockquote dir=ltr style="MARGIN-RIGHT: 0px">
<p>C:\Documents and Settings\NetworkService\Local Settings\Application Data\Microsoft\Windows Media Connect 2\FileScanLogFile.txt</p></blockquote>
<p>Sometimes more detailed error information can be found.&nbsp; This file can be quite large so it may take some time to find the particular file that you are interested in.<br/></p>]]></content:encoded>
    </item>
    <item>
      <title>My Digital Media Receiver can’t see Windows Media Connect</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/my-digital-media-receiver-cant-see-windows-media-connect</link>
      <pubDate>Wed, 01 Feb 2006 01:37:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2006/02/01/my-digital-media-receiver-cant-see-windows-media-connect/</guid>
      <description><![CDATA[You’ve got everything hooked up and Windows Media Connect (WMC) can see your Digital Media Receiver...]]></description>
      <content:encoded><![CDATA[<p class=MsoNormal style="MARGIN: 0in 0in 0pt">You’ve got everything hooked up and Windows Media Connect (WMC) can see your Digital Media Receiver (DMR) but your DMR can’t see WMC. This one is very interesting.<span style="mso-spacerun: yes">&nbsp; </span>Let’s take a look at what could cause this problem.</p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">When the DMR wants to find WMC (or vice versa) it sends out an SSDP MSEARCH request.<span style="mso-spacerun: yes">&nbsp; </span>When a UPnP device that matches the parameters of the search hears the broadcast it responds with its own announcement.<span style="mso-spacerun: yes">&nbsp; </span>Alternately, WMC sends out an announcement every five minutes or so to advertise its presence.<span style="mso-spacerun: yes">&nbsp; </span></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">Let’s imagine what could go wrong.<span style="mso-spacerun: yes">&nbsp; </span>First, the MSEARCH may not be getting to WMC.<span style="mso-spacerun: yes">&nbsp; </span>This could be caused by bad cables, bad routers, or firewalls.<span style="mso-spacerun: yes">&nbsp; </span>I’ve already covered how to fix all of those, because they would also block WMC from seeing the DMR.<span style="mso-spacerun: yes">&nbsp; </span>If you’ve got Internet connectivity for your PC and your DMR you can eliminate cables as the cause.<span style="mso-spacerun: yes">&nbsp; </span>Next, I’d eliminate the router by connecting directly. If that still didn’t work, I’d start disabling the firewalls. That isn’t really a problem at this point, because you aren’t connected to the internet if you aren’t connected to your router, right?<span style="mso-spacerun: yes">&nbsp; </span>Don’t ever disable your firewall while connected to the internet.</p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">There is another scenario that should be considered when WMC can see your DMR, but not the other way around.<span style="mso-spacerun: yes">&nbsp; </span>It is actually the UPnP Content Directory Service (CDS) that the DMR goes looking for. WMC won’t advertise a CDS if there are no files shared.<span style="mso-spacerun: yes">&nbsp; </span>Basically, WMC won’t advertise an empty library.<span style="mso-spacerun: yes">&nbsp; </span>So, what could cause an empty library?<span style="mso-spacerun: yes">&nbsp; </span>Two things come to mind. First, if you never completed the first-run wizard then there are no folders shared. No folders shared, means no files shared. No files shared means no CDS.<span style="mso-spacerun: yes">&nbsp; </span>Even though WMC can find the DMR, the DMR doesn’t have a CDS to find.<span style="mso-spacerun: yes">&nbsp; </span>Second, you may not have permission to read the files that you’ve shared.<span style="mso-spacerun: yes">&nbsp; </span>No access to the files means no files shared.<span style="mso-spacerun: yes">&nbsp; </span>And no Files Shared means no CDS.<span style="mso-spacerun: yes">&nbsp; </span>I’ve seen this happen most with domain joined PCs (see my last article).<span style="mso-spacerun: yes">&nbsp; </span>For one of the reasons discussed in that article WMC can’t validate that the user has access to the files, so it doesn’t share them.<span style="mso-spacerun: yes">&nbsp; </span>The result is again no CDS for the DMR to find.</p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">So, when you start up WMC for the first time, do it from a local account that has administrator privileges and complete the first run wizard even if you can’t find the DMR.<span style="mso-spacerun: yes">&nbsp; </span>You need to do that to be sure that there is a CDS to find later.<span style="mso-spacerun: yes">&nbsp; </span>The rest of the troubleshooting steps are the same as in the case where WMC can’t find the DMR.</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Media Connect and Domains</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/windows-media-connect-and-domains</link>
      <pubDate>Mon, 30 Jan 2006 10:41:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2006/01/30/windows-media-connect-and-domains/</guid>
      <description><![CDATA[A surprising number of people are running domains in their homes.&nbsp; Windows Media Connect (WMC)...]]></description>
      <content:encoded><![CDATA[<p class=MsoNormal style="MARGIN: 0in 0in 0pt">A surprising number of people are running domains in their homes.<span style="mso-spacerun: yes">&nbsp; </span>Windows Media Connect (WMC) can work on a domain joined PC.<span style="mso-spacerun: yes">&nbsp; </span>Nearly every computer at Microsoft is joined to one of the corporate domains.<span style="mso-spacerun: yes">&nbsp; </span>That was true of me as well as I worked on WMC. So, I daily streamed music from a domain joined PC from WMC.<span style="mso-spacerun: yes">&nbsp; </span>However, there are some issues to be aware of with domain joined PCs.</p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">For those of you with a domain controller at home, make sure the computer running WMC has been added to the Windows Authorization Access group in Active Directory.<span style="mso-spacerun: yes">&nbsp; </span>Also, you have to either disable IPSEC on your domain or configure the WMC computer as a boundary machine so that it can communicate with non-IPSEC devices.<span style="mso-spacerun: yes">&nbsp; </span></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">For those of you who have a home computer joined to a corporate domain you have less control over your situation.<span style="mso-spacerun: yes">&nbsp; </span>What I’ve done in this situation is to log in with the local administrator account (a non-domain account) and do my folder sharing from there.<span style="mso-spacerun: yes">&nbsp; </span></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">There are two basic problems here that have to be overcome.<span style="mso-spacerun: yes">&nbsp; </span>The first is simple connectivity.<span style="mso-spacerun: yes">&nbsp; </span>IPSEC encrypts part of the packets.<span style="mso-spacerun: yes">&nbsp; </span>There isn’t any shipping Digital Media Receiver (DMR) that I know of that support IPSEC.<span style="mso-spacerun: yes">&nbsp; </span>So, if you want basic connectivity with a DMR you are going to have to communicate with it without using IPSEC.</p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></p>
<p class=MsoNormal style="MARGIN: 0in 0in 0pt">The second issue that has to be overcome is basic file permissions.<span style="mso-spacerun: yes">&nbsp; </span>WMC is a service that runs under the NETWORK SERVICE account.<span style="mso-spacerun: yes">&nbsp; </span>In order to share the files over the network it must have access to them. At service startup it walks through its list of shares and checks to see if the person who shared the files has access.<span style="mso-spacerun: yes">&nbsp; </span>In the case of the domain joined PC that person is a domain user.<span style="mso-spacerun: yes">&nbsp; </span>Therefore it must interact with the domain to determine access.<span style="mso-spacerun: yes">&nbsp; </span>The NETWORK SERVICE account won’t have access to the security information of the user who shared the folder if the machine isn’t added to the Windows Authorization Access Group in Active Directory.<span style="mso-spacerun: yes">&nbsp; </span>Since the service can’t validate that the user who granted the shares has permission on the files it won’t expose a server. This same situation arises when a Domain Joined PC is disconnected from the domain (as when you bring home a corporate laptop).<span style="mso-spacerun: yes">&nbsp; </span>The NETWORK SERVICE account can’t communicate with the domain to validate file permissions and therefore it won’t expose a server.<span style="mso-spacerun: yes">&nbsp; </span></p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Media Connect can’t see my DMR: IV</title>
      <link>https://docs.microsoft.com/archive/blogs/alan_ludwig/windows-media-connect-cant-see-my-dmr-iv</link>
      <pubDate>Fri, 27 Jan 2006 10:12:00 GMT</pubDate>
      <dc:creator><![CDATA[Alan Ludwig]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/alan_ludwig/2006/01/27/windows-media-connect-cant-see-my-dmr-iv/</guid>
      <description><![CDATA[You've been trying to get it to work but Windows Media Connect (WMC) doesn’t see your device, and...]]></description>
      <content:encoded><![CDATA[<P>You've been trying to get it to work but Windows Media Connect (WMC) doesn’t see your device, and neither does the UPnP Subsystem.&nbsp; We figured that out by running the script pasted to the blog a few entries back.&nbsp; What could be causing this?&nbsp; Let’s get past a few basic questions before we get usual causes. If you’ve been following along the posts in order, you’ve already worked through these issues.&nbsp; If not, be sure to address these first, before you continue.</P>
<P>Did the script give an error?&nbsp; This could be caused by the UPnP Services not being started.&nbsp; Go look at this post: <a href="https://blogs.msdn.com/alan_ludwig/archive/2006/01/20/515333.aspx">https://blogs.msdn.com/alan_ludwig/archive/2006/01/20/515333.aspx</A></P>
<P>Does basic internet connectivity work?&nbsp; Do you have a router?&nbsp; Check out this post, and make sure you are testing with a “direct” and “wired” connection: <a href="https://blogs.msdn.com/alan_ludwig/archive/2006/01/18/WMCOverview.aspx">https://blogs.msdn.com/alan_ludwig/archive/2006/01/18/WMCOverview.aspx</A></P>
<P>If it still doesn’t see the device the most likely cause is some kind of firewall.&nbsp; For basic discovery, the ports that must be opened in the PC firewall have already been discussed here: <a href="https://blogs.msdn.com/alan_ludwig/archive/2006/01/23/516232.aspx">https://blogs.msdn.com/alan_ludwig/archive/2006/01/23/516232.aspx</A>.&nbsp; But, since firewalls are the most likely problem in if you’ve gotten this far then this is a good place to review all of ports and why they need to be opened.&nbsp; Here’s the full list of ports that are used by WMC: 1900 UDP,2869 TCP,10243 TCP, 10280 – 10284 UDP.</P>
<P>In previous posts, I’ve already covered what is done with 1900 UDP, and 2869 TCP.&nbsp; Port 1900 is used for SSDP discovery.&nbsp; This is where the multicast device announcements come in.&nbsp; I’ve also already covered what happens on port 2869 TCP.&nbsp; This is the main port for all UPnP traffic.&nbsp; UPnP is basically HTML and SOAP, so essentially there is a web-server at 2869 TCP.</P>
<P>Port 10243 TCP is used by WMC to actually stream the media to the PC.&nbsp; Basically, there is a web server on this port.&nbsp; The Digital Media Receiver (DMR) uses UPnP on port 2869 to get a list of the music, video, or photos that are available.&nbsp; When it is ready to play music (for example) it gets the URL of the song from UPnP and then requests it.&nbsp; The port in that URL is port 10243.&nbsp; The web server then streams the music to the DMR on that port.</P>
<P>Ports 10280 – 10284 UDP are used by Windows Media Digital Rights Management for Network Devices (WMDRM-ND) as part of the device registration process.&nbsp; I’m not going to go into great detail about what they are used for since the internals of DRM are beyond the scope of this post.&nbsp; But if you’d like to play-back protected music, then these ports need to be open.&nbsp; Having these ports block will not interfere with discovery or even keep unprotected content from playing back.&nbsp; </P>
<P>WMC was tested and works perfectly well with the Windows firewall. If you don’t have a 3rd party firewall, then there is no reason to go in and adjust or turn off the windows firewall.&nbsp; The most you should need to do to get the windows firewall working correctly with WMC is to go into the advanced tab on the windows firewall and choose “Restore Defaults”.&nbsp; After that go into the WMC User Interface (UI) and choose “Reset” under the firewall section.&nbsp; If you’d like to make especially sure that it isn’t the windows firewall then you can disable it.&nbsp; But, I would only do that if you are physically disconnected from the internet.&nbsp; If you ever review your firewall logs you’ll see that when you are connected to the internet (especially an always-on broadband connection) you are attacked every few minutes at most. Don’t disable your firewall while you are connected to the internet.</P>
<P>For 3rd party firewalls you should seek help from your firewall provider.&nbsp; From the newsgroups and web-forums that I visit I’ve heard a whole range of things that people had to do to get WMC working with 3rd party firewalls. I’ve heard everything from “I just opened the ports” to “I had to completely uninstall the firewall”.&nbsp; Again, my advice is always the same.&nbsp; If you are using a 3rd party firewall and you disable or remove it to troubleshoot WMC, don’t do that while you are connected to the internet.&nbsp; </P>
<P>I highly recommend using firewall software.&nbsp; It is critically important to have that protection.&nbsp; Personally, I use the built-in windows firewall. I don’t use a 3rd party firewall on any of my computers.&nbsp; My primary source of security is the firewall in my hardware router.&nbsp; As a second layer of security I use the built-in Windows Firewall.&nbsp; I’ve run all kinds of security scans available from reputable sources and when running in this configuration they all give me passing marks. As part of my security practices I run real-time virus detection software as well as a full scan every night (automatically scheduled while I sleep).&nbsp; I also have ad ware and spyware protection. The only downside (in theory) to not running a 3rd party firewall on my computer is that I don’t control or block outgoing connections.&nbsp; With the two incoming firewalls, and the ad ware and virus protection packages I don’t feel like this is a fatal security flaw.&nbsp; Most folks don’t have the expertise to actually make good decisions about the validity of a particular outgoing connection so in the end I don’t think it helps much anyway.&nbsp; Mostly it is just annoying to keep the list of “authorized applications” up to date and to deal with the constant pop-ups from the 3rd party firewall to authorize a particular connection or application.</P>
<P>That’s my whole rant on firewalls and how to troubleshoot them.&nbsp; But, that isn’t the whole list of things that could be causing problems.&nbsp; If your PC is a member of a domain there&nbsp; a few other issues that you could run into.&nbsp; I’ll cover those next time.<BR></P>]]></content:encoded>
    </item>
  </channel>
</rss>