Nick’s Blog

Sunny, warm, and weekend soon

by Nick on Apr.08, 2011, under Blogging

Could it get any better?

Leave a Comment more...

ORM Why?

by Nick on Mar.08, 2011, under Development

Or more precisely why not! I guess I could be counted as one of those old school developers that is now just a little stuck in his ways. I started writing software more than thirty years ago and I have seen a lot of progress in my time. There is little doubting that writing an application now is far easier than it ever was and developers now are free to focus on the problem rather than having to focus on how to solve the problem.

(continue reading…)

Leave a Comment :, , more...

Inserting a geometry into a SQL Server 2008 Database

by Nick on Dec.09, 2010, under GIS

I’m not sure why but it seems that there is a lack of documentation surrounding how you get spatial data into and out of a SQL server 2008 database. Some people resort to using WKT (well known text) others serialise to a binary format. I was not happy with either approach, I mean inserting data into a database should be relatively straightforward.

So before we go anything further. Here is the code I created to create a SQL Server 2008 point geometry and insert it into a table with two columns. The first column was an auto increment ID and is not shown, the second is called LOCATION and is defined as a Geometry as far as SQL Server is concerned.

private void Add(Point point)
{
   SqlGeometryBuilder builder = new SqlGeometryBuilder();
   builder.SetSrid(900913);
   builder.BeginGeometry(OpenGisGeometryType.Point);
   builder.BeginFigure(point.X, point.Y);
   builder.EndFigure();
   builder.EndGeometry();
   SqlGeometry geom = builder.ConstructedGeometry;
   SqlCommand cmd = _dbConnection.CreateCommand();
   cmd.CommandText = "INSERT INTO READING (LOCATION) VALUES (@geometry)";
   SqlParameter param = cmd.Parameters.AddWithValue("geometry", geom);
   param.UdtTypeName = "Geometry";
   cmd.ExecuteNonQuery();
}

The Point type that is passed in is my own and simply contains an X and a Y. The types SqlGeometryBuilder and SqlGeometry are defined in Microsoft.SqlServer.Types which requires that you install Microsoft SQL Server System CLR Types which you can find via http://www.microsoft.com/downloads/en/details.aspx?FamilyID=228de03f-3b5a-428a-923f-58a033d316e1&DisplayLang=en. Something that fooled me was that after installing this I expected the reference to be in the GAC. Well it isn’t, or at least it isn’t on my machine and instead I had to browse to C:\Program Files\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SqlServer.Types.dll. 

The lines to note are

   SqlParameter param = cmd.Parameters.AddWithValue(“geometry”, geom);
   param.UdtTypeName = “Geometry”;

The first adds the Geometry object as a parameter and the second tells SQL Server what kind of UDT (or user defined type) we are using. Strange that it was not possible to devise a way to make Geometry and Geography fully fledged types but the extra work is very little.

Leave a Comment :, , , more...

MVVM

by Nick on Nov.12, 2010, under Silverlight

I was recently watching a video presenting the concepts behind Microsoft’s newish programming model MVVM (Model, View, View Model). You can find the video within the article here. The reason for watching the video was that I really wanted to know what MVVM was and I really cannot complain about the content from that point of view. After watching the video I had a clearer understanding of what MVVM is. (continue reading…)

Leave a Comment :, , , more...

Tatuk GIS

by Nick on Sep.25, 2010, under GIS

I’ve been using Tatuks DK.Net version 9 for about a year now. The choice to use Tatuk was not mine but rather it appears to have been financially driven by predecessors and I have to say price performance is very good. You pay only for a license for each developer and are then free to distribute the applications to as many users or customers as you want.

The DK includes a control for the display of maps within the application that is capable of displaying data from a wide range of spatial data sources (http://www.tatukgis.com/Products/InternetServer/Features.aspx) including all the major ones such as ESRI, Oracle Spatial, WKB, WKT, and most common raster formats. The control also supports printing templates allowing the map to be printed with a border and text adornments.

Along side the visible mapping capabilities, the DK also includes an amount of spatial processing capabilities. You can filter spatially or create buffer zones and much more. It all adds up to making creating a map with Tatuk quite easy.

There are, however, some downsides. While the DK is very fast with shapefiles this appears only to be because it loads vast amounts (or possibly all) the data into memory. This really does give us a very fast map but as we add data from other sources the memory usage builds up and the map slows down. Performance with Oracle Spatial is currently proving a headache for us as clients are insisting on adding every layer available to them and making map rendering times to say the least sluggish.

To add to this problem we find that the DK cannot share layer information between map instances. We wanted to build an application with maps in several places. The main screen contains a map and the fact that startup time is not quick is not really a problem, however we would have liked to have had auxiliary maps on various other forms in the application. However those instances cannot be made to share information with the main map and so have the same memory usage and startup time.

Another weakness of the DK appears to be that it only operates on the GUI thread. I did some tests early on with running the DK on another thread and I was able to get it to do some work but not by doing anything that was Tatuk approved. The reason I wanted DK to run on another thread was simply that every time the map renders the entire GUI stalls. I had hoped that the slower layers could be rendered on a separate thread while the faster raster layers gave context to the user.

In all I think Tatuk is a great product and for the price you’ll find it hard to do better. The guys at Tatuk are supremely helpful and willing to look into most problems. However you can try to push it too far and perhaps our product is doing that.

Leave a Comment :, more...


Humax 5050

by Nick on Sep.08, 2010, under Blogging

This device is a digital PVR with a fair sized hard disk capable of recording from digital channels. I would like to write a full review but really there is enough information out there to let you know what the machine is technically capable of. So really I’m only going to summarise the things I like and the things I dislike about the device.

Overall the device is an improvement on the Panasonic device that I’ve owned for years. For a start you can schedule two digital channels for recording at the same time and watch a third. However the Panasonic device was never intended for digital recording and is already 8 years old.

Given the intervening years I would have expected some major improvements but ignoring the three tuners for a moment and that it picks up programme information over the air there is little to recommend the device. Let’s start with setting the device up. (continue reading…)

1 Comment :, , , , , more...

Point order in spatial data (or it depends how you look at it)

by Nick on Apr.27, 2010, under GIS

I was battling with a new GIS application and started getting complaints from some people that the points were being ordered wrongly. Now I have always known that the point order in some spatial systems is important. Mostly I rely on the software between me and the storage to correct the order before saving and this time was no different. I am using the products of a relatively small Polish outfit called TatukGIS. They have made quite a nice product and are helpful when things go wrong. Their product is a viewer and middleware that allows many different spatial formats to be read or written to. You can read more on their site http://www.tatukgis.com/

Now as a use of an application I can imagine that as you draw a polygon, that represents the boundary of your garden for example, you are not concerned in which order you draw the points (clockwise or anticlockwise) but in theory it makes a difference. I’ll try and describe the reason as best as I can. There are two ways to explain it, the Oracle way that I learned a while ago and the WKT (well known text) way that I’ve only just read. To be honest both make sense but the WKT way perhaps gives a little more information than the Oracle way.

Firstly Oracle simply says that a polygon exterior is a list of points that must be filled counter clockwise. (See 2.2.4 of the spatial data types and meta data documentation.) Now I was always told that the explanation was you need to imagine yourself walking around the exterior, on your left is the interior. So, in theory, if you specify the points on the other order then everything outside your garden would become garden and only the bit inside would be not garden (nice mistake if you can get the land registry to make it). But Oracle also says that any holes in your garden must be specified clockwise. Well if you think about this for a moment (taking the classical doughnut as an example) it makes perfect sense. You walk around the outside of the doughnut anticlockwise and everything on your left is doughnut, walk around the hole clockwise and again everything on your left is doughnut.

Secondly the WKT way. WKT is a way of formatting geometries in a standard fashion that is supported by many databases and can easily be used within databases that do not natively support spatial information because the format is purely text (there is also a WKB version, a binary format, that is more efficient with the storage but is not human readable). Their documentation (section 6.1.11.1) states “The exterior boundary LinearRing defines the “top” of the surface which is the side of the surface from which the exterior boundary appears to traverse the boundary in a counter clockwise direction.”. Now if you consider this for a moment it sounds like exactly the same thing and really it is. But suppose once again that you look at your garden, draw out the points in a clockwise fashion and then hand the map to someone that does not know your garden. They might conclude that either a) you have made a mistake b) your garden is best viewed from the underside or c) your garden occupies the entire map with the exception of the small bit in the middle.

I would suggest that most people will conclude alternative a) that you have made a mistake. And it seems that this is the alternative that a large number of software packages makes (including Tatuk and GeoMedia). However they are guessing at your mistake and perhaps you really do have a massive garden. Move to three dimensional data and the difference becomes less clear. In three dimensions how can you tell  which side is the top of something, and what does top really mean? Suppose you have a drawing of cube that represents a water tank. What order would you draw the points of the bottom panel of the tank? Does the top of that panel point downwards or upwards? And what about the sides?

If you are wondering about the idea that your garden could occupy the entire globe then imagine a spherical world (a bit like earth perhaps) and draw an island round one of the poles. Now imagine how this island might look if you were to try to draw this map on a flat piece of paper. It would probably look simply like a straight line running along the top of the paper. Now how do you decide which side of the line is land and which is water? Now imagine and island that covers half of the globe. It does not matter which half, you will always need to somehow decide which is inside and which is outside.

I said earlier that I would revisit this and add some information about other file formats. The next file format up is the shapefile from ESRI. According to the ESRI definition of the shapefile (see page 9) the order of the points is opposite to that of the previous two formats that I listed. This does, of course, pose a risk for those developing tools to read from one format and write to another, and that is that they have to reverse the order with each read/write. Not that this is any reflection on ESRI, actually the shapefile format pre-dates  both of the previous two formats.

Microsoft have been fairly slow to recognise the necessity of spatial capabilities in their database but 2008 has finally seen the introduction of two new data types. Geography for storing geodetic (real world) data and geometry for storing planar data. Hopefully their time spent catching up also means they have overtaken some of the now elderly formats and engines.  For the geometry type Microsoft states that the point order does not matter. They go on here to say :-

The OGC Simple Features for SQL Specification does not dictate a ring ordering, and SQL Server does not enforce ring ordering

Which seems at odds with the earlier reference that I gave earlier stating that it does matter. However that was a draft specification so perhaps they later dropped the requirement. I can quite see how a polygon on a planar system is unambiguous but WKT is not solely used for planar systems.  Clearly a little more homework is required.

For the MS SQL Server Geography type the point order is important but the documentation I read did not say what the ordering should be. What they did say is that no geometry using a geography data type may be larger than a hemisphere and that there is effectively no such thing as an inner or and outer ring. This last point might sound like non-sense but actually it makes perfect sense.

Imagine an island that has two lakes. Now make the island so big that it covers nearly the entire planet. Does it really make sense to call one of the exteriors the outer? In other words anything that is not dry land is outside the island. Let us imagine that one of the lakes has an island of its own. And suppose the island has a school. Now you perform a query to find which schools lie on the original outer island, is the school on the island in the lake of the island included. No! Not if you are using the geometry of the main island.

But I can imagine that there are circumstances where this theoretical lack of distinction would get in the way. Suppose I want to know where all the schools are within the territory of the main island. In most other systems I’d load up my polygon, delete any interior holes and then query the database. Only under SQL Server  that will not be possible because I have no idea which is my outer, they are all outers. I might be able to iterate over the outers and find out which is the largest and delete the rest.

I am going to have to come back to this topic to make it complete for other databases and file formats.

Leave a Comment :, , , , , , , , more...

I’m an Evony Cheater

by Nick on Apr.09, 2010, under Rants

At least according to Evony I am. They sent me a little email a fews days ago (6 April 2010)

Account Action: Suspension

Reason for Action: Terms of Use Violation

Greetings,

After a thorough investigation, we have found that the account listed above violate the terms of use listed below:

Use cheats, automation software (bots), hacks, mods or any other unauthorized third-party software, databases or scripts designed to modify the Evony experience.

You may not perform any acts that we consider to be damaging to Evony. While we try to be as lenient as possible, and take in consideration many mitigating circumstances, the reoccurring offensive trends listed above have led to the suspension.

This Evony account has been suspended for 3 days by the Account Administration staff based on a review of the account and all related policy violations. Be aware that any additional inappropriate actions may result in the permanent closure of the account.

This action has been taken in accordance with the Terms of Use and our In-Game Policies.

Only the Account Administration department can address disputes or questions you may have about this account action. To learn more about how we are able to assist you, please email to escalation@evony.com.

Regards,

Account Administration

The Evony Team

IMPORTANT NOTE: Please do not respond to this email. Any email sent as a response to this message will not reach us. Should you have another question or would like to send us additional information, please contact us by emailing escalation@evony.com.

Well what surprised me was that this came shortly after I’d decided to give up on the game and had not logged in for several days. I had two cities and one of them was attacked and taken over. It had taken me so long to build the city that I figured that I really did not have enough time to build it again. But I did not want my attacker to then go on and reap the rewards of taking over my other city (or at least clearing it out) so I proceeded to hold a fire sale. I sold everything for next to nothing. I built a new city near by. Moved everyone into the new city and abandoned the old one. I then teleported my new city away and never logged in again.

A few days later I heard about their new game. It promised a better experience with no bullies. I was curious and created an account on their beta server. I played for a few minutes before realising it was just the same game with a fancy interface and some woman commentating on everything you do. Oh well done my Lord you really are turning out to be a super Evony customer. Realising that it was going to be every bit as dreary as the old game I abandoned that one too and then I received the mail saying I was a cheat and that my account was locked.

So I wrote back to Evony

Hello Account Administration,

Firstly which account listed above? You appear not to have listed any account in the mail. However given that you have sent the mail to this email address I guess you are either talking about the beta account or the live account.

Secondly I can categorically tell you that I have not used any cheats on either account (unless using Firefox counts as cheating). You might well be thinking that they all say that but well really this time it is true. To my knowledge I have not logged in since sometime last week when someone mounted an attack on one of my cities and I decided enough was enough and stopped playing. To be honest I’d already got bored of playing Evony as it seemed that to do anything required endless waiting around. But given that you are accusing me of cheating based on what must be false information (or the possibility that my account has been hacked) you might want to dig a little deeper in case you are falsely accusing other users who might actually give a damn.

Hang on a moment. I did try to flog off all my stock before destroying the city. The logic went like this. Someone clobbered my main city. I then thought they would probably attack my other city next and frankly did not want to give them the satisfaction of getting something for nothing. So I flogged everything for 0.0001 gold. To my surprise I seemed to earn an absolute fortune for doing so. That is not cheating, that is a bug in your sloppily written code. I then abandoned the city, gold and all, and relocated the other city out of reach of the attacker and then never logged in again.

Finally please feel entirely free to delete both accounts (beta and live) that are associated with this mail address and then remove me from all future mailing lists.

and got a standard out of office reply telling me to wait 5 days before complaining that they did not answer.

Dear Customer,

Thank you for contacting the Evony support center.  To better assist
you, we have forwarded your customer service request ticket to a
specialized department that handles issues which you are reporting.

We ask that you be patient while that department reviews and
investigates your customer service request ticket in detail.  As
reviews and investigations can take time for us to replicate your
issue, we might be making contact to you asking specific questions
regarding your ticket if the department feels it cannot replicate or
investigate an outcome based on your report request.

Please do let us know if you feel you have not after 5 business days
received a timely response and we will escalate the ticket
accordingly.

Thank you,
Evony Support

So I was not entirely filled with hope that the issue would ever be resolved and joined the community at bbs.evony.com and found that, far from being the only one claiming to have been falsely locked out, there seems to be large group of people all saying “Hey I’m innocent”. They all tell the same or similar story. Suddenly they are locked out and Evony refuse to enter into a discussion about it. I never spent money with them but there are players who claim to have done exactly that and then get barred. I really feel sorry for those people.

Well I’m still within the 5 days notice period. My account might be unlocked today but frankly I do not care. I just want to highlight my innocence and then get on with life in the real world. So if you are thinking of starting to play Evony please do a little research. It is a fun game initially but the threat of suspension is hanging over everyone. Here is section 8 of the TOC’s

REGAN MERCANTILE US, LLC MAY SUSPEND, TERMINATE, MODIFY, OR DELETE ACCOUNTS AT ANY TIME FOR ANY REASON OR FOR NO REASON, WITH OR WITHOUT NOTICE TO YOU

If you have also been accused of cheating then please feel free to drop me a comment and if you have your own blog I’d be happy to link to it. Please make sure your comments are accurate and not abusive otherwise they will not be posted.

If you are interested in a little more reading about the game here are a few links to get you started.

http://www.bruceongames.com/2009/08/25/evony-want-to-sue-me-for-telling-the-truth/

http://www.bruceongames.com/page/2/?s=evony

http://ezinearticles.com/?Evony—Game-Free-Forever&id=3720754

http://www.brighthub.com/video-games/mmo/articles/46094.aspx

http://www.articlesbase.com/computers-articles/evony-games-free-forever-1856785.html

http://www.funclub92.com/2010/04/evony-drops-libel-lawsuit-against-uk-blogger.html

1 Comment :, , , , , , , more...

You know how it is.

by Nick on Mar.14, 2010, under Rants

You are brought up in a Christian school and told of the certainty of God, how he is looking out for us and how kind and good he is. You soon find that there are millions of people around the world that are starving and how the Church is doing good works to try to help these poor people. You might start to wonder why God does not help them but this is explained because God has given us free will. (continue reading…)

Leave a Comment :, , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!