A new ZoomLevelCollection was established for Saskatchewan data, to provide yet another opportunity to tweak the paging mechanism to see if performance can be improved for these very large data sets. The script to generate and modify the instances of base.ZoomLevel associated with this collection was stored under ..\Saskatechewan\ZoomLevelDefinition.sql.
To summarize up to this point, wells have been grouped geographically using progressively smaller tiles* as the user zooms in. It makes sense that as the tile decreases, the likelihood of a single well occupying the tile increases. Given this, why not come at the problem from the other direction? In other words, assume exactly one well per KML in all cases, and then use KML’s NetworkLink construct as a mechanism for determining whether a given well is displayed, or not. Also, assuming this approach is adopted, each KML will have its own unique URL, and therefore is potentially visible to search engines. That is, if the Sitemap.xml thing can be made to work as advertised.
To accommodate the two types of zoom level, the id_Type column was added to base.ZoomLevel, and two types of zoom level established;
Tile This is the current type of zoom level, and is based on the division of the viewing area into equally-size tiles containing one or more wells. All artifacts with the tile are either displayed, or not. It will typically be used for lower (looser) zoom levels to convey distribution patterns using a statistically significant number of wells without having to display all wells. The name of the resulting KML reflects the co-ordinates of one of the corners of the page. [id_Type = 133]
Point This new type is based on establishing a zone around a single well, and having the well appear based on this zone being active (or not). Typically used for the tightest (highest) zoom level to convey all relevant data associated with the well. There is a maximum of one well per KML, and the name of the resulting KML is based on Well.uid. In the case of this type, the amt column became optional, as the number of wells is always one. The check constraint CK_ZoomLevel was added to enforce this business rule. [id_Type = 134]
Generating the Point-type KMLs turned out to be quite a different job than generating Tile-type KMLs. Rather than further butcher the logic of E.getWellGroupKml, a new stored procedure, E.getWellKml, was developed more-or-less from scratch. It’s able to crank out Point-type KMLs in the blink of an eye — good thing, because there are potentially so many of them — for the 100,042 wells found in Saskatchewan, there will need to be 100,042 associated KMLs.
Next, E.getWellRegenerateTxt was coded to generate the .BAT text which contains all of the calls to E.getWellKml, which, in turn, generates the individual KML files. A file called regenerate.bat was created to contain this text, and let loose to generate all of the KMLs. It was finished just minutes later, or so it seemed, for a total of 100,042 KMLs, one for each well in Saskatchewan.
The potentially vast number of KMLs is not a problem, in and of itself, except the physical handling of this large number of files tends to time-consuming. Uploading them to the Intellog server was the biggest challenge. Of all the different approaches tried (CDs and the like), the best one still seems to be good ol’ FileZilla. 100,042 files were queued for upload, and while it took some time to do it, FileZilla eventually uploaded all 100,042 files. It didn’t take that long, either, given the excellent Internet connection that’s available. About the biggest problem was FileZilla reporting 421 Too many connections (8) from this IP every couple of hundred files. The latter problem eventually seemed to clear itself in each case, and the uploads continued on. After 36,766 uploads, for instance, 88 had failed for this reason and had to be requeued. The problem was sent over to the ISP to see if the number of IP connections could be bumped up.
Finally, code was hacked together (and stored under Untitled3.sql, for the time being) which contains the logic to generate all of the NetworkLinks. The first attempt to use the resulting file — with it 100,042 NetworkLinks in it — seemed to indicate it was activating all of the NetworkLinks, but some more testing is required in this regard.
One certain problem encountered with this approach was the seeming inability of a KML containing the NetworkLink to cascade style information into the linked file. The KML Reference clearly indicates that styleUrl is a legitimate child of NetworkLink. In other words, if you want the Placemark in the linked file to be scaled at 0.80 with one NetworkLink, and scaled to 0.25 with another NetworkLink in the same file you should be able to do it. But, alas, it does not seem to be possible. About the closest thing is to have a styleUrl in the linked file make reference back to style information in the file containing the NetworkLinks themselves. This approach was as succinctly described by TJ1 on KML Developer Support.
Code Shavings The user-defined function base.getFilenameTxt() was incorporated into E.WellSymbolDetail VIEW. It seems to me, though, that it should really be named base.getFileNm()? ♦ Although it was done some time ago, the column id_Type_extendedData was added to the base.ZoomLevel table. There are currently two codes associated with it; Full and Abbreviated. Full is the entire set of extended data associated with the Google Earth (GE) Placemark which generates the well symbol, and Abbreviated is a slimmed-down version which was implemented to make the KMLs a little smaller. ♦ E.getRegenerateTxt was modified to incorporate a temporary table to store results prior to returning them. It’s so the style generation and the page generation calls to sqlcmd are returned as one set of records, rather than two. ♦ The column styleLbl to E.WellSymbolDetail. It’s basically the same as the nm column, except no extension.
*In previous posts, these were referred to as pages. It would seem as though the common parlance is ’tile’, however. Therefore the term ’tile’ will be used in this and future posts.