Showing posts with label mapguide-rest. Show all posts
Showing posts with label mapguide-rest. Show all posts

Sunday, 13 September 2026

What happened to that plan?

5 months ago, I laid down the plans for what was going to happen going forward with my various open source projects. But after that post, it has been nothing but ... silence! If you were to look at my GitHub contribution graph, there was also a noticeable drop-off there too.

So what happened?

What happened was there was a major rug-pull. GitHub copilot changed their pricing model to usage-based billing on June 1 and that completely threw by GH copilot powered plans into complete disarray. The existing subscription at that point pretty much amounted to ~30 spins on the AI slot machine per month, hoping it will produce the outcome I desire and that was just untenable for something I am paying out of my own pocket!

So come June 1, I terminated my GitHub copilot pro subscription and pondered what my next moves were going to be. I wasn't going to give up on the productivity gains that agentic coding gave me, so the option was clearly to look for alternative AI coding provider. Because try as I might (I religiously keep watch on advancements in LocalLlama), locally hosted AI coding models is not (yet) tenable on my personal hardware. I bought that PC to 6 years ago to last a decade at least, and it will still last a decade as long as you give up on locally hosted AI models as desired workload.

I eventually settled on Deepseek and straight away, its payment model was very attractive to me: Just load up your account on credits and reload when credits start running low. This was a low risk approach where I loaded up $20 $10 USD in credits, give it a spin on my various open source projects. If Deepseek didn't pan out for my use cases, no harm, no foul. I simply don't reload with any more credits. But if it did work out for me, I can just load more credits as I go.

So as my initial $20 $10 load is down to its final dollar after several months of sporadic evaluation. I can confidently say that Deepseek adequately meets my AI coding agent needs while maintaining the "bang for buck" that I used to have with GH copilot before their June 1 rug-pull. I will lose some capabilities from GH copilot (cloud agents was nice), but they are acceptable losses.

So what that means in the grand scheme is that I should start ramping up my OSS dev machinery again and resume the plans that I had stated 5 months ago. Our regular broadcasting will resume shortly!

Wednesday, 13 November 2024

Announcing: mapguide-rest 1.0 RC6.1

I've taken a momentary break from our (admittedly) glacial pace of MapGuide development to put out another release of mapguide-rest 

This release includes the following changes:

  • Fix missing reverse routing on selection overview
  • Fix bad feature query preparation when querying against watermarked layers
  • Relax strict-typing on MgReaderToGeoJsonWriter::FeatureToGeoJson() so that it can work with MgPaginatedFeatureReader allowing pagination to work again
  • Added missing properties parameter to swagger defn for session-based feature selection route

We now return to regularly-scheduled programming of trying to get MapGuide Open Source 4.0 to the finish line.

As for mapguide-rest, I envision at least once more major RC *after* the final release of MapGuide Open Source 4.0 before finally wrapping things up on development work and pulling the trigger on the mapguide-rest 1.0 final release. Enough of this RC-after-RC business!

Monday, 4 December 2023

Announcing: mapguide-rest 1.0 RC6

6 years later, I have finally put out another release of mapguide-rest!

The reason for finally putting out a new release (besides being long overdue!), is that I needed a solid verification of the vanilla SWIG API binding work for MapGuide Open Source 4.0 and mapguide-rest was just the ideal project that touches almost every nook and cranny of the MapGuide API. So if mapguide-rest still works with the PHP binding in MapGuide Open Source 4.0, that is as good of an endorsement to the reliability and readiness of these bindings.

For this release of mapguide-rest, it is compatible with the version of PHP that comes with:

  • MapGuide Open Source 3.1.2 (PHP 5.6)
  • MapGuide Open Source 4.0 Beta 1 (PHP 8.1)
Besides being compatible with the upcoming MapGuide Open Source release (and the current stable one), this release also adds a new series of APIs to perform various geo-processing tasks. All of which are available to try out in the interactive swagger API reference.




Special thanks to Gordon Luckett and Scott Hamiester for assistance in internal testing of many internal builds of mapguide-rest that finally culminated in this long-overdue release.

Now that this is out of the way, it is back to MapGuide development proper and getting closer to the 4.0 release.

Friday, 5 May 2023

The "I haven't forgotten about you $PROJECT" tour

As I said near the end of my MGOS 4.0 Beta 1 announcement, I will be momentarily stepping away from MapGuide development/maintenance to give some of my sibling projects in the MapGuide/FDO space some long-overdue attention.

So for the next few weeks, I will be embarking on the "I haven't forgotten about you $PROJECT" tour with stopovers at the following projects:

mapguide-react-layout

Next Release: 0.14.8

Objectives: This will be the last release in the 0.14.x series and the last release to officially support Internet Explorer.

MapGuide Maestro

Next Release: 6.0m12

Primary Objective: This release will have authoring parity with MapGuide Open Source 4.0 Beta 1
Secondary Objective: Assorted fixes and minor enhancements

FDO Toolbox

Next Release: 1.5.3

Objective: Some fixes for bugs and usability problems reported since 1.5.2

mapguide-rest

Next Release: 1.0 RC6

Yes! I am finally giving this project some very-overdue attention!

Primary Objective: Make sure it is compatible with PHP 8.1 that is bundled with MapGuide Open Source 4.0 Beta 1. Also doubles as a secondary sanity test of the new vanilla SWIG-generated PHP bindings, which is my main motivator for revisiting this project.

Secondary Objective: See if we can do this will still being able to support older PHP versions bundled with older MapGuide versions. If this is not tenable, we may need to branch codebases and make separate releases. I hope that this is not the case.


When I finish this tour, then I will be returning to get MapGuide Open Source 4.0 to the final release finish line



Friday, 6 March 2020

MapGuide tidbits: An unconventional way to bulk convert features to GeoJSON

Recently in my regular day job I had a spatial data processing task that needed to be carried out in a timely manner.

I needed the current Australian Federal Electorates, which come from the AEC in the form of a single SHP file or MapInfo TAB file and I needed this dataset split up so that each of the 151 federal electorates existed as separate GeoJSON files named based on some combination of attributes in each feature.

After deliberating on possible solutions (I absolutely did not want to have to write a throwaway program that uses GDAL/OGR or FDO to do this conversion unless there was no other choice!), I came up with a somewhat unconventional solution using mapguide-rest and its data publishing feature that I've decided to share in this particular post. Here's what I did.

First, I loaded the electorates SHP file into the MapGuide Server via Maestro. The feature source can be either connected to the SHP file loaded into the resource data files or connect to an external SHP path or aliased path. It ultimately doesn't matter and it's up to you how you prefer to manage your SHP feature sources.


This MapGuide installation already has mapguide-rest installed, so I use the REST Explorer in Maestro to connect to it. Once connected, I proceeded to create 2 data configurations.


The first one is a CSV representation of the SHP feature source, that returns the identity and a computed expression of my desired output file name.


The resulting REST configuration looks like this:


We then set up a 2nd REST configuration to provide a GeoJSON representation of our electorates.


Whose REST configuration looks like this


With these 2 rest configs set up, we now have new URLs available to us to access the electorates in our desired representations. In relation to what I want to achieve, the URLs of interest are:

GET http://servername/mapguide/rest/data/electorateinfo/.csv

To get the id and desired filename of all electorates in a CSV, whose content looks like this:


The other URL is:

GET http://servername/mapguide/rest/data/electorate/{id}.geojson

To get the individual electorate feature by id in GeoJSON format.

With these 2 URLs, we now just need to write a simple script that:
  1. Downloads the CSV of all electorates
  2. Loops through each line in the CSV (except header) to request a GeoJSON download of the electorate for the given id and download it as the requested file name.
Which can be done with a Powershell script like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$csvFile = [System.IO.Path]::GetTempFileName();
$workingDirectory = Convert-Path (Resolve-Path -path ".")
$outDir = "$workingDirectory\electorates_geojson"
New-Item -ItemType Directory -Force -Path $outDir
Invoke-WebRequest -Uri "http://localhost/mapguide/rest/data/electorateinfo/.csv" -OutFile $csvFile
$electorates = Import-Csv $csvFile
foreach ($elec in $electorates) {
    $id = $elec.FeatId;
    $fileName = $elec.filename + ".geojson";
    $outPath = [System.IO.Path]::Combine($outDir, $fileName);
    Invoke-WebRequest -Uri "http://localhost/mapguide/rest/data/electorate/$id.geojson" -OutFile $outPath
    Write-Host "Saved electorate ($id) to: $outPath"
}

Run the script, and a minute or 2 later, all 151 electorate boundary features have been split off and converted into individual GeoJSON files!


I hope this post is as useful to you as it was for me.

Tuesday, 3 January 2017

Announcing: mapguide-rest 1.0 RC5

Here's a long awaited new release of mapguide-rest.

This release is PHP 5.6 compatible (so it will work with MapGuide Open Source 3.1, that bundles PHP 5.6) and includes various fixes that can be found in the referenced change log

Download

So ... what's stopping me from putting an end to these endless 1.0 RC releases?

I need to answer (and commit to it) the age old question of: What is the best strategy for versioning REST APIs? Currently, I'm leaning towards the "put the version in the URL" approach. If you have played around with the mapguide-rest addin for Maestro, that is what the "v1" in the url represents when you connect to mapguide-rest from Maestro.


The bits I still have to figure out is once the "v1" API is set in stone, how do we evolve the API afterwards. I need a solid plan for post-v1 API evolution in place before I can slap the 1.0 final label.

Saturday, 6 August 2016

MapGuide tidbits: mapguide-rest and PHP 5.6

Since MapGuide Open Source 3.1 Beta 2 shipped with PHP 5.6, some might be wondering if my mapguide-rest extension will work on this version of PHP (from a compatibility standpoint, we mainly are referring to the MapGuide API itself, which is the same as before, and not the surrounding Web Tier environment like PHP, Tomcat, etc).

The good news is: Yes, it works for the most part

I say that because, if you see a message like this:

Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version

It's because of some some deprecation warnings that are active in PHP 5.6. This message in particular, is due to the setting always_populate_raw_post_data not being disabled in php.ini.

And for another interesting fact? It's not set to 1, which should imply the setting is disabled right? Well you guessed wrong, it has to be explicitly set to -1 in php.ini for it to be disabled. Once disabled, these warning messages go away.

Another thing to look out for from the client-side is that PHP 5.6 may include charset in its Content-Type response headers. So if your client code was previously testing for application/json
exactly for a JSON response, that may fail now because PHP 5.6 will most likely send down application/json; charset=utf-8 instead. If you have such code, adjust accordingly.

But besides that, my mapguide-rest function test suite says things are A-OK with this release of PHP.

For a better out-of-the-box experience, we'll look to have this setting default to -1 in the php.ini we ship with MapGuide.

Saturday, 30 January 2016

Announcing: mapguide-rest 1.0 RC4

Here's the 4th (and I am most certain, the last) release candidate of mapguide-rest 1.0

Here's what's new in this release

CORS support

CORS support has been added, allowing for cross-domain AJAX requests to be made to mapguide-rest. This is opt-in and has to be enabled by un-commenting the MapGuide.Cors section in config.php

New Selection APIs

New APIs have been added to make it easier to work with selections

You can see these APIs in action with the updated kitchen sink sample application




Updated Swagger UI

The version of swagger UI and spec we use has been updated. Where possible JSON/XML content parameters have an associated model schema giving you an idea of how the content should be structured



Other Changes



Download

Wednesday, 2 December 2015

Announcing: mapguide-rest 1.0 RC3

Here is the long awaited 3rd release candidate of mapguide-rest 1.0.

The main new feature (yeah, probably went a bit too early with that "release candidate" label) is a new set of APIs to:

  • Easily manipulate layer/group structure of a runtime map
  • Easily manipulate map selections non-spatially through a more simpler selection XML syntax
Which is demonstrated in various new sample applications included in this release.

Firstly, we have a new cesium.js sample demonstrating how to consume a mapguide-rest XYZ tile set using the new UrlTemplateImageryProvider


We also have a new example using the turf.js geometry library for slicing and dicing GeoJSON map selections client-side, which can then be saved server-side into a session-based layer and be incorporated into the map itself.


Since our sample applications use both OpenLayers 3 and cesium, we've also have an XYZ tile sample that uses both thanks to the ol3-cesium integration library.


And there's many more sample applications to try out. (NOTE: The vector tile example is broken in this release, I'm looking to fix that in the next release)

Other changes in this release include:
  • The whitelist configuration introduced in the previous release, is now extended to cover resource service APIs as well
  • Fix inability to walk nested directory structures for data publishing configuration files
  • Allow anonymous access to feature aggregate API
  • Allow custom root directory for storing XYZ tiles
  • Classify MgConnectionFailedException as a HTTP 503 error
  • The selected features route can be restricted to certain property names like the other routes that return feature data
  • XYZ tiles (not served from a Tile Set Definition) should no longer have labels/symbology anomalies at tile boundaries as mapguide-rest now renders out "buffered" XYZ tiles and crop the result to the original 256x256 size
  • GeoJSON output now covers the full set of supported geometry types
I'm certain this release will be the last one before I put the final 1.0 stamp on it. Other than documentation cleanup, and some performance testing I do not see anything of a show-stopping nature that impedes me from making the next release the 1.0 final release.

Monday, 13 July 2015

GovHack 2015 post-mortem

Last year, I said I would be interested in attending the 2015 iteration of GovHack. Well, this time round, I almost didn't make it. I didn't get wind about the tickets for this years event being available until 5 days after the initial announcement and it seems that was enough time for tickets to be sold out. Well fortunately, one Saturday before the event, I get the email notification that I'm off the wait-list so I claimed that available ticket before it was too late and I was locked in for GovHack: Round 2.

Although I did have a idea about what to build this time round, the key materials needed to make this idea work arrived too late to realistically execute this idea of mine, so I've put that idea on ice (yes this whole preceding sentence is kept intentionally vague :)).

Compared to last year, this time round was much smoother. Team was assembled quickly, we had several potential ideas worth pursuing for the next 46 hours. In the discussions that followed it was decided that we should have an interactive map. Cue my map expertise ... :)

So armed with my brand new hackathon-grade ASUS Zenbook that I acquired a few months earlier, we set forth to build ... yet another MapGuide concoction.


Unlike last year, this time round wasn't a load-everything-into-MapGuide and house it in a Fusion application affair. This time round, we looked to build a MapGuide application geared towards modern browsers and mobile devices, using the building blocks of OpenLayers 3, Bootstrap and Knockout.

The end result, is our GovHack 2015 entry: The VET provider map.


The VET provider map allows people to look for Vocational Education and Training (VET) providers in the state of Victoria. With this map, people can search for:

  • VET providers
  • Occupations (which would then show related pathway courses and the providers that offer them)
  • Courses (offered by a provider, that is a pathway to a given occupation)



Unfortunately, due to time constraints the (bits that I mentioned in parentheses) could not be completed within the weekend, meaning that while you could search for courses and occupations, the crucial link to the actual providers on the map that offered such courses is not there. Still, what was implemented should convey what we are trying to achieve with this application.

The search capabilities are powered by the data publishing framework of mapguide-rest, which gave our spatial data sources ready-to-go (Geo)JSON APIs for our application to use, and also "cleaner" JSON property names (pet peeve of this hackathon: Dealing with property length limitations of the SHP file format and undesirable property/column names. Ugh!)

Other features of this map include:

Popups driven by QUERYMAPFEATURES responses from point-based marker selections (applicable for VET provider markers)


A modal-based legend/layer toggler that shows when you hit the "Layers" button on the map viewer.


And finally, the whole application is responsive.


But don't take the word of my gifs and screenshots, you can see the map in action for yourself from our demo site linked on our hackerspace page. Once again, the demo site is hosted on a Amazon EC2 micro instance (be gentle :)). If you're interested in the source code and data that drives this map, you can find that on our GitHub repo. Be sure to vote for our entry if you can.

Thanks to the team (Ling, Tim and Hans) for your coding, data acquiring, wrangling and video production efforts. It's been a blast!


Until next time ...

Thursday, 11 June 2015

Announcing: mapguide-rest 1.0 RC2

Here's the second release candidate for mapguide-rest 1.0

The main addition in this release is support for defining a "whitelist" in config.php that will restrict feature service APIs to only the specified operations and feature sources defined in the whitelist, allowing you to reduce the attack surface of your mapguide-rest install by only controlling API access to feature sources of your choosing. You can find a commented-out whitelist example in config.php that you can adapt to your own installation.

Other changes and fixes include:
  • Fix runtime map XML generation for versions of MapGuide that do not support CREATERUNTIMEMAP
  • Fix XYZ routes for Tile Set Definition resources
  • Support a bboxistargetcs flag that allows the bbox parameter of any feature query route to be declared in the coordinate system indicated by the transformto parameter
  • Display of error response stack traces can now be toggled in config.php
  • Fix invalid GETMAPIMAGE operation version in map image adapter
  • When doing a search result query via the data publishing framework, if the query produces a single result, the "single" view template will be shown instead of the "many" view template
  • When doing a search result query via the data publishing framework, if the query produces no results, the "none" view template will be shown instead of the "many" view template
I'm thinking there will probably be at least one more RC after this as there is still some more attack surface reduction work to do before I can confidently slap a 1.0 final label on it.

Download

Friday, 6 March 2015

Announcing: mapguide-rest 1.0 RC1

I've decided that mapguide-rest has enough features to lock in the 1.0 version number.

Here's what's new in this release.

Cleaner JSON responses

If you've used JSON output from mapguide-rest or MapGuide proper, you'll notice that the JSON is ugly and cumbersome to use:
  • Every JSON property is an array
  • All property values are strings
The main reason this JSON is so ugly is because of the way that XML is converted to JSON. The conversion process knows nothing about the content model of the XML document it is trying to convert, so as a lowest-common-denominator solution, it forces all converted XML elements to JSON array properties and all XML text elements as string values. While this allows for rudimentary usage by client applications, it's not a pleasant experience.

For this release, we've set out to solve this problem. The JSON produced which would've looked like this:


Now looks like this:


How did we achieve this? Simply put, we now maintain a hard-coded list of known XML element paths (compiled from all the MapGuide XML schemas) and make note of:
  • Which paths must always be processed as a JSON array
  • Which paths have values whose data type is not a string
With this list, we now know which XML elements need to be converted to JSON arrays and which elements need to be converted to JSON property values, and the proper data type to convert such values to.

The end result is that the new JSON responses are much more natural and intuitive to work with. Not to mention these new JSON responses are smaller than their previous counterparts. Those extra [ and " characters do add up.

This is a PHP-level solution. With this release, all JSON conversion/output is now handled by mapguide-rest. While slower than doing it natively in MapGuide, it gives us more usable JSON structures and this increased usability is worth it for the slower performance.

As for the old JSON response structure, that is going away in mapguide-rest. This new structure will be used for all APIs in mapguide-rest that return JSON. If you want the old JSON structured responses, you'll have to go back to the mapagent.

In one particular case, we eschew the convert-to-JSON-from-XML approach and define a new dedicated JSON response format. 

Ever tried to describe the schema of a Feature Source? This is the XML response:


Have you seen the JSON version of this monstrosity?


How on earth would any sane person know how to use this response in their applications? Yeah me neither.

So for schemas and class definitions that are returned as JSON, we introduce a more cleaner and intuitive JSON format


Isn't that a more intuitive and self-explanatory JSON response?

This new response structure is only applicable for JSON schemas and class definitions. The XML version of these schemas and class definitions will still be its same ugly and verbose self. From my perspective, XML is the "legacy" response format in mapguide-rest. JSON is the preferred response format for any client application and so we should strive to make consuming such data in this format as simple and clean as possible. With this release, hopefully we've achieved that objective.

While we're still on the subject of JSON, for certain REST APIs that previously accepted XML request bodies, such APIs now support JSON-equivalent request bodies. For example, consider this route to set resource content:

POST /rest/library/{resourcePath}/content.xml

To set resource content, you'd make a POST request to this route and include the resource XML as part of the request body.

You can now set the same resource content via its JSON representation

POST /rest/library/{resourcePath}/content.json

By making a POST request to this route and include the equivalent JSON as part of the request body. Because our JSON formats now structurally follow their XML counterparts, knowing what JSON to construct should be easy to figure out. On the server-side such JSON bodies will be converted back to its XML counterpart before passing down to the underlying MapGuide APIs (because sadly XML is still the canonical format for storage and data transfer throughout the official MapGuide APIs)

Authoring APIs for restcfg.json files

We've added a set of new APIs in the data publishing framework to allow for restcfg.json and any supporting files to be uploaded from a mapguide-rest client without needing physical access to the directory where the restcfg.json files are stored.

These authoring APIs allow you to:

  • Upload a restcfg.json file to a desired subdirectory within mapguide-rest based on the given URI part
  • Upload any supporting files to the subdirectory mapped to the given URI part
  • Delete any restcfg.json configuration
  • Delete any supporting file of a restcfg.json configuration
Because URI parts are mapped to physical subdirectories within a mapguide-rest installation, there could be a opportunities for malicious activity without proper security precautions. To this effect, we do the following:
  • Such APIs require Administrator or Author-level roles to be assigned to the authenticated user. The MapGuide Anonymous users will not have such roles, and thus any attempt at accessing these APIs will be denied.
  • Any URI parts and filename parameters are sanitized to strip off any semblance of relative paths and any other path navigation tricks that would cause mapguide-rest to save/delete a file or directory outside of its installation directory.

You can find out how to use these new APIs in the built-in interactive API reference.

API additions and cleanups

APIs that previously returned simple primitive values now return a XML or JSON boxed version of that value. Simply put, if an API returned a boolean value like this:

true

It will now return a boxed value, which looks like this for XML:


And looks like this for JSON:

{ "PrimitiveValue": { "Type": "Boolean", "Value": true } }

While this looks more verbose, it is simply to provide a consistent developer experience. If you have been expecting XML or JSON responses for 99% of the APIs, why make an exception for this 1% of APIs that return basic primitive values? They should be XML or JSON respectively as well and in order for that to happen, we have to box such values.

In addition many new APIs have been added to cover missing pieces and loose ends in our REST API:

  • Creating Feature Sources
  • Setting and deleting resource data items
  • Listing Long Transactions of a supported Feature Source
  • Getting the coordinate system base library
  • Validating Coordinate System WKT
  • Converting Coordinate System WKT to EPSG codes
  • Testing the connectivity of a Feature Source
  • Enumerating unmanaged (aliased) data
  • Getting site information status/statistics
  • DescribeSchema with class name hint
  • Setting content and header of any resource in a single request
  • Fusion layout authoring support APIs
  • Interrogating and setting the edit-ability of a Feature Source with the REST API

You can find out how to use these new APIs in the built-in interactive API reference.

(Geo)JSON CRUD support in restcfg.json

The data publishing framework now supports CRUD for JSON representations. The JSON representation is much more simpler and compact in its request payloads. The requests to create, update and delete features are structurally the same as the XML one (using the same XML-to-JSON pattern for most of our JSON data structures)

The existing Editable Properties example has been modified to use the JSON representation instead of the XML one. For doing CRUD through the data publishing framework, I'm sure you'll find it much easier to work with this JSON representation than the XML one.

Customizable HTML representation

The HTML representation for features are now customizable and localizable as the previous bits of hardcoded HTML that were rendered out by the HTML renderer, have all been extracted out into Smarty templates, where you can customize the HTML to your own liking.

MapGuide 3.0 support

This release of mapguide-rest supports new features introduced in MapGuide Open Source 3.0.
  • Your tile service routes can also work with Tile Set Definitions
  • XYZ tile requests will pass through to the MapGuide API on a MGOS 3.0 install
  • Runtime Map responses use the v3.0.0 response schema
Other changes
Where to from here?

From now to the final 1.0 release of mapguide-rest, it will be nothing but bug fixes and (really) minor enhancements.

After 1.0 as I've somewhat hinted, if mapguide-rest as a project should have a continued evolution, I strongly believe it should be on the ASP.net 5.0 platform. Given ASP.net 5.0 won't see light for many more months, I'll have plenty of time to play and experiment with many ideas that are possible with ASP.net 5.0

Friday, 7 November 2014

Announcing: mapguide-rest 0.11.2

Here's another release of mapguide-rest. There was some issues that cropped up after pushing the original 0.11 release that necessitated 2 emergency point releases to fix. As a result, 0.11.2 is the official release.

Here's what's new in this release.

KML Service Support

mapguide-rest now provides RESTful routes that wrap the existing KML Service APIs in MapGuide:

  • /library/{resourcePath}.MapDefinition/kml
  • /library/{resourcePath}.LayerDefinition/kml
  • /library/{resourcePath}.LayerDefinition/kmlfeatures
These routes respectively wrap or replicate:
  • GetMapKml (re-implemented in PHP to write the correct RESTful URLs for NetworkLink) elements)
  • GetLayerKml (re-implemented in PHP to write the correct RESTful URLs for NetworkLink) 
  • GetFeaturesKml (wraps existing API)

Pagination support for feature data routes

These following routes that return feature data now support pagination:

  • /library/{resourcePath}.FeatureSource/features/{schema}/{class}
  • /library/{resourcePath}.FeatureSource/features.{type}/{schema}/{class}
  • /library/{resourcePath}.LayerDefinition/features
  • /library/{resourcePath}.LayerDefinition/features.{type}
  • /session/{sessionID}/{mapName}.Selection/features/{layerName}
  • /session/{sessionID}/{mapName}.Selection/features.{type}/{layerName}

You can paginate the results by passing two additional parameters:

  • pagesize - The number of features to return per "page"
  • page - The page "number" to return
Pagination will work for any supported representation except for CZML. The implementation of CZML output is not compatible with our pagination and errors will be thrown if attempting to pass in pagination parameters for CZML output.

The primary beneficiary of pagination support is ...


HTML representation for feature data

We've added HTML representations for feature data routes:
  • /library/{resourcePath}.FeatureSource/features.{type}/{schema}/{class}
  • /library/{resourcePath}.LayerDefinition/features.{type}
  • /session/{sessionID}/{mapName}.Selection/features.{type}/{layerName}
Where {type} can now be html in addition to the existing supported representations.

For example, a html representation of a Layer Definition would look like this



Apply pagination, and you now have a page-able view of your feature data


The real payoff for implementing this feature is that you also get this support for selected features. For selected features, we support changing the display orientation in the HTML representation as well.


Tweak the page size and orientation parameters for this route and you have what is now effectively a selected feature property palette for your custom map viewer for free, as demonstrated in a new sample that is bundled with this release.


The palette in this sample is just an iframe to this new HTML representation URL.

Improved HTML repository view

The HTML repository representation has been cleaned up

You'll notice each resource no longer show all actionable links. That's because these have been moved to a separate page that is loaded when you click on the resource link.

Clicking on any actionable link will show the result in the space below


We've also added more actionable links for the following resource types:

  • Feature Sources: View features as HTML
  • Map Definitions: Export as KML

Various other HTML representations have also cleaned up css.

Localization-ready

mapguide-rest is now localization ready. If you want to translate mapguide-rest to your language of choice, you just have to do the following:

  • Translate and copy the strings in app\res\lang\en.php to app\res\lang\{locale}.php. A small caveat with translating these strings is that you will have to translate the content in a way that respects the ordering of placeholder tokens as we use sprintf to fetch and format localizable strings.
  • Translate and copy the system templates under app\res\templates\en to app\res\templates\{locale}
  • Translate and copy the XSLT templates under app\res\xsl\en to app\res\xsl\{locale}

Once you have translated these files, simply change the Locale property to {locale} in app\config.php and mapguide-rest will use the translated strings and templates

Other changes/fixes

  • Client agent and IP addresses are now recorded when creating a site connection, ensuring all API access from mapguide-rest will be properly logged in the server's access.log
  • Fix layered PDF plotting for maps with base layer groups
  • Added various bits of missing REST API documentation
  • Error messages will now be returned in the appropriate requested format where applicable (eg. If an error occurs when making a request to a URL expecting an XML response, the error will be returned as XML). If no applicable request format can be determined, then the default error response will be in HTML.

Download

Tuesday, 16 September 2014

Announcing: mapguide-rest 0.10

Nope, this isn't a 1.0 release. Not only are we not using decimal release numbers, but there's still plenty of things to explore and refine before we can put the 1.0 stamp on this thing. Here's what's new and changed in this release.

(Experimental) Cesium CZML support

We now have support for outputting feature data as CZML for consumption inside the Cesium 3D web viewer. Support for CZML is made available as a representation of a given Layer Definition.

For example, the following route will return data from the trees layer as CZML:

http://localhost/mapguide/rest/library/Samples/Sheboygan/Layers/Trees.LayerDefinition/features.czml

We've included a CZML example in this release that demonstrates the level of support that has been implemented for this release.


When selecting an object, its tooltip data will be shown in Cesium's information window if available.


Note the object itself has no selection indicator unless the object is a point. Still trying to figure out if we can apply a different style for selected lines and polygons.

If your Layer Definition has elevation settings applied, they be extruded if they're polygons


Now if the (experimental) tag didn't stand out, here's the current limitations with this implementation:
  • The following properties are preserved when converted to CZML, anything not listed can be assumed lost in translation:
    • Point styles: Point color is preserved. The point size in CZML is the average of the height/width of the point as defined in the Layer Definition.
    • Line styles: Line color
    • Area/Polygon styles: Fill color. Outline color
  • If a Layer Definition has multiple scale ranges defined, mapguide-rest will only consider the first scale range when outputting CZML
  • If a given point/area/line style is themed, the default rule (the one without a filter) is ignored
Data publishing improvements

The restcfg.json now lets you specify a Layer Definition as the data source instead of a Feature Source and Feature Class name.

Also, when using a Layer Definition as a data source, you'll get tooltip, hyperlink and elevation FDO expression pre-evaluated, allowing you to use such computed properties within your templates.

You can find a new example that uses the building footprints from the Melbourne dataset.

File download support

Most GET routes can now prompt for downloads by appending download=1 to the query string of the URL.

XYZ tile improvements

Vector tiles can now be for a base layer group or for a layer within the base layer group.

Just to recap, this URL route fetches a vector tile for a given base layer group in a Map Definition

http://servername/mapguide/rest/library/{resourcePath}.MapDefinition/xyz/{groupName}/{z}/{x}/{y}/tile.{format}

If you want vector tiles for a specific layer within that group, you can use this new URL route

http://servername/mapguide/rest/library/{resourcePath}.MapDefinition/xyz/{groupName}/{layerName}/{z}/{x}/{y}/tile.{format}

You can find a new Leaflet example that uses the single-layer vector tiles.


Other changes

  • Fixed bad download links in the resource data list HTML representation
  • Fixed invalid chunked file transfer behavior under certain conditions
  • Samples updated to use OpenLayers 3 final and Cesium 1.1

Wednesday, 10 September 2014

Make that 3/3

Thanks to this thread, I was finally able to crack the missing piece of the CZML output puzzle for mapguide-rest, and we can now output point, line and polygon features as CZML to Cesium.


CZML is a representation of a Layer Definition in mapguide-rest, this means we will get pre-evaluated properties to play with such as:

We currently use this information as follows

Tooltips get written as the description property of each CZML packet, allowing such information to be displayed in the Cesium information window when the object is selected.


Now as the above screenshot shows, there's no real visual way to know what object you selected. I'm still figuring out if there's a way in CZML or the Cesium APIs to specify how a selected object looks so it can stand out.

If the Layer Definition has elevation/extrusion settings applied, that's when the fun stuff happens. We apply the extruded value in the CZML packet for each feature, giving us 2.5D features. This extrusion only applies for polygon features at the moment.


Oh, and did you know Cesium works pretty well on any WebGL capable mobile browser?


Pretty cool stuff. Now that we've nailed down the fundamentals, it's time to figure out how much visual fidelity we can preserve from MapGuide to CZML:

  • Can we transfer thematics?
  • Can we transfer labels?
  • Can we transfer patterns?
  • Others?
Fun times ahead!

Friday, 5 September 2014

2/3

After lots of trial and error, I am finally able to output features from MapGuide as CZML to Cesium via mapguide-rest


However, only 2 out of the 3 geometry types are working (points and polygons). I'm still trying to figure out:
  • How to properly output CZML for line features
  • How best to apply Z extrusion where it is defined in the Layer Definition
  • What parts of a Layer Definition are transferable/translatable to CZML? Doesn't have to be 1:1. KML-level visual/information fidelity would suffice here.
If only there were more comprehensive CZML examples I could refer to that would make implementing this stuff much easier! All the examples I could find try to demonstrate every bell and whistle when all I want to know is where do I stick the lat/lon/elevation coordinates from my source geometries? Their CZML documentation could do with some improvement, a single-page document is terribly hard to navigate and without reference examples it's amazing I was even able to get this far!

But in the end, all this pain and struggle will be worth it because Cesium is just plain awesome! I truly believe that Cesium will be to 3D maps what OpenLayers is to 2D maps: A powerful web-based map viewing platform that is rich in features and support for many different vector and raster data sources.

Saturday, 2 August 2014

Announcing: mapguide-rest 0.9

Here's a new release of mapguide-rest, packed with some new toys.

PDF Support

The existing URL routes for DWF plotting now also support PDF output.

For example, a DWF plot URL like this:

http://localhost/mapguide/rest/library/Samples/Sheboygan/Maps/Sheboygan.MapDefinition/plot.dwf?x=-87.73&y=43.74&scale=8000



Can be turned into a PDF plot like this just by replacing the .dwf in the URL to .pdf:

http://localhost/mapguide/rest/library/Samples/Sheboygan/Maps/Sheboygan.MapDefinition/plot.pdf?x=-87.73&y=43.74&scale=8000


When plotting from a session-based runtime map, you also have the option of producing a layered PDF. To produce a layered PDF, simply append layeredpdf=1 to a PDF plot URL on a session-based runtime map. This takes longer to plot than a normal PDF, but the resulting PDF will have a toggle-able layer structure



Queryable Layer Definitions

The existing URL routes to query feature data from Feature Sources can now also be applied to Layer Definitions.

For example, suppose you originally were querying Parcels from its Feature Source

GET http://localhost/mapguide/rest/library/Samples/Sheboygan/Data/Parcels.FeatureSource/features.xml/SHP_Schema/Parcels?maxfeatures=500

You can now also query the same data via a Layer Definition that points to it

GET http://localhost/mapguide/rest/library/Samples/Sheboygan/Layers/Parcels.LayerDefinition/features.xml?maxfeatures=500

You'll notice that querying via Layer Definitions means you don't have to include the fully-qualified FDO class name in the URL as that will be inferred from the Layer Definition document. Also when querying via Layer Definitions, it will also include evaluated tooltip and hyperlink expressions for each feature (as MG_TOOLTIP and MG_HYPERLINK properties)

The Layer Definition query route supports the same parameters as the Feature Source one and supports GeoJSON output as well.

New Samples

We've added a new OpenLayers 3 example, demonstrating how to consume dynamic GeoJSON vector layers from the REST API


And a new Cesium example, also consuming GeoJSON from the REST API


Other Changes

  • GeoJSON features now include id attributes containing the identity property value. Previously the identity property value was written out as a regular feature property.
  • Improved XYZ tile cache resiliency
  • Feature query routes (ie. selecting features) no longer require an authentication challenge and can be done anonymously.
  • Feature query responses are no longer internally buffered, reducing response wait times.


Download