Google Earth 3D model web service - google-earth

In Google Earth, I have a <gx:Track> which has a <model> element (https://developers.google.com/kml/documentation/kmlreference#model).
The model has a <Link> element in which the <href> defines the collada (dae) model to be used.
When working with files on my computer, I can manually set the <href> to a local path (eg c:\temp\model.dae") and the model displays correctly.
Now I want write a web service to return model.dae dynamically. I'm having trouble figuring what format google earth is expecting with regard to Content Type / Content Disposition / content.
I have tried ContentType = "model/vnd.collada+xml" and Content-Disposition = "attachment; filename=""collada.dae""" but Google Earth fails to load the model without any errors.
Have also tried "Content-Disposition", "inline;"
Please can anyone point me in the right direction?
Thanks

After a more digging around....
https://groups.google.com/forum/#!topic/kml-support-server-side-scripting/Lh3xR2GTBc8
So, just need .ContentType = "text/xml" and .ContentEncoding = Text.Encoding.UTF8. No need to specify anything for content-disposition
Ah well, hope this is of use to someone else in the future.

Related

Novacode LineChart type

I have a code that implements a Novacode.LineChart. And the LineChart type which is shown by default is this one:
But I dont want this type of chart, I want it without points, like this:
This is the code where I create the chart:
LineChart c = new LineChart();
c.AddLegend(ChartLegendPosition.Bottom, false);
c.Grouping = Grouping.Stacked;
Anyone knows how can I hide thoose points and show only the lines? Thanks to everyone!!
Your question is shown up while I was searching for the exact same feature. It's probably a bit late but I hope it would be useful for other people in need of this feature.
My so called answer is not more than a few lines of dirty and unmanageable hack so unless you are not in dire need, I do not recommend to follow this way.
I also do not know if is it an approved approach here but I prefer to write the solution step by step so it may help you to grasp the concept and use better methods.
After I have realized that I was unable to use DocX to create a line chart without markers, using currently provided API, I wanted to know what were the differences between actual and desired output. So I saved a copy of .docx file with line chart after I manually edited the chart to expected result.
Before and after the edit
As you may already know, a .docx is a container format and essentially comprised of a few different folders and files. You can open it up with a .zip archive extractor. I used 7-Zip for this task and found chart file at location of /word/charts/chart1.xml but this may differ depending on the file, but you can easily figure it out.
Compared both of chart1.xml files and the difference was, the file without the markers had and extra XML tag with an additional attribute;
<c:marker>
<c:symbol val="none" />
</c:marker>
I had to somehow add this segment of code to chart. I added these up to example code provided by DocX. You can follow up from: DocX/ChartSample.cs at master
This is where the fun begins. Easy part first.
using System.Xml;
using System.Xml.Linq;
using Xceed.Words.NET;
// Create a line chart.
var line_chart = new LineChart();
// Create the data.
var PlaceholderData = ChartData.GenerateRandomDataForLinechart();
// Create and add series
var Series_1 = new Series("Your random chart with placeholder data");
Series_1.Bind(PlaceholderData, "X-Axis", "Y-Axis");
line_chart.AddSeries(Series_1);
// Create a new XmlDocument object and clone the actual chart XML
XmlDocument XMLWithNewTags = new XmlDocument();
XMLWithNewTags.LoadXml(line_chart.Xml.ToString());
I've used XPath Visualizer Tool to determine the XPath query, which is important to know because you can't just add the marker tag to somewhere and expect it to work. Why do I tell this? Because I appended marker tag on a random line and expected it to work. Naive.
// Set a namespace manager with the proper XPath location and alias
XmlNamespaceManager NSMngr = new XmlNamespaceManager(XMLWithNewTags.NameTable);
string XPathQuery = "/c:chartSpace/c:chart/c:plotArea/c:lineChart/c:ser";
string xmlns = "http://schemas.openxmlformats.org/drawingml/2006/chart";
NSMngr.AddNamespace("c", xmlns);
XmlNode NewNode = XMLWithNewTags.SelectSingleNode(XPathQuery, NSMngr);
Now create necessary tags on newly created XML Document object with specified namespace
XmlElement Symbol = XMLWithNewTags.CreateElement("c", "symbol", xmlns);
Symbol.SetAttribute("val", "none");
XmlElement Marker = XMLWithNewTags.CreateElement("c", "marker", xmlns);
Marker.AppendChild(Symbol);
NewNode.AppendChild(Marker);
And we should copy the contents of latest changes to actual XML object. But oops, understandably it is defined as private so it is a read-only object. This is where I thought like "Okay, I've fiddled enough with this. I better find another library" but then decided to go on because reasons.
Downloaded DocX repo, changed this line to
get; set;
recompiled, copied Xceed.Words.NET.dll to both projectfolder/packages and projectfolder/projectname/bin/Debug folder and finally last a few lines were
// Copy the contents of latest changes to actual XML object
line_chart.Xml = XDocument.Parse(XMLWithNewTags.InnerXml);
// Insert chart into document
document.InsertChart(line_chart);
// Save this document to disk.
document.Save();
Is it worth it? I'm not sure but I have learned a few things while working on it. There're probably lots of bad programming practises in this answer so please tell me if you see one. Sorry for meh English.

Getting routes on openstreetmaps using OSRM

I've been trying to get a list of co-ordinates in a route from point A to B using OSRM with the following request:
GET http://router.project-osrm.org/viaroute?hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760
However, on opening the url, i find the 'via_points' tag containing only two co-ordinates. Surely, that can't be the entire route? Anything I'm missing here? Is there any other way of generating the list of route co-ordinates with OSRM? Thanks
The route is contained in the route_geometry object. It is an encoded polyline. If you don't want to uncompress it yourself you can disable compression via compression=false:
http://router.project-osrm.org/viaroute?compression=false&hl=en&loc=47.064970,15.458470&loc=47.071100,15.476760
Not sure what the via_points contains. OSRM's documentation seems to be outdated. Maybe they are just your start and end points snapped to the nearest road or something similar.

Show orion context broker poi in map viewer

For learning porpoises I am trying to run the default map viewer set up and show the POIs stored in the orion public instance (orion.lab.fi-ware.org:1026).. but it does not work at all.
Following screenshots with the default provided configurations. It should show a bunch of Santander POIs if I understood well.
1.-Wired mashups schema:
2.- NGSI Source default settings:
3.- NGSI entity to POI default settings:
4.- Map viewer default settings:
5.- Map viewer result (No results at all :(( ):
Everything looks pretty straight forward but nothing is shown. Without understanding why it is not working I can not moving forward and work in my own implementation.
thanks in advance.
It looks to me like you have not obtained an authorization token (or you are not showing it in your question?). Without one you are not able to retrieve information from orion.lab.fi-ware.org.
One way to get a token is running this python script:
https://github.com/telefonicaid/fiware-figway/blob/master/python/get_token.py
Of course, you do need a FIWARE Lab account to get it.
The problem seems to be in the configuration of the "NGSI entity to POI". The Node, AMMS and Regulators entities provide their coordinates using the Latitud (latitude) and Longitud (longitude) attributes.
The final value for the "Coordinate attribute" setting should be: Latitud, Longitud

How to Convert IPicture to Image - .NET 4.5 TagLib Sharp

I am wanting to display the album artwork of a song (accessed via the taglib-sharp library) within a Windows Forms picture box. The problem I'm running into is that the taglib-library returns an image of type TagLib.IPicture whereas the picture box requires an object of type System.Drawing.Image.
I have scoured the internet for many hours now, looking for a way to convert from an IPicture to Image, but to no avail. The best lead I have is this: http://msdn.microsoft.com/en-us/library/system.windows.forms.axhost.getpicturefromipicture.aspx, but I have yet to see a successful example of how to implement this.
Any help as to how to convert between these two types would be much appreciated. Note: IPicture is not analogous to IPictureDisp in this case.
I've done the opposite before - turning an existing .jpg into an IPicture for embedding in an .mp3 file. I just tried reversing that operation and, after tweaking and testing, came up with this:
TagLib.File tagFile = TagLib.File.Create(mp3FilePath);
MemoryStream ms = new MemoryStream(tagFile.Tag.Pictures[0].Data.Data);
System.Drawing.Image image = System.Drawing.Image.FromStream(ms);
Thanks for the question - I already know how I'm going to use this myself!
Update: Here's the other way (.jpg to IPicture that I've done before):
tagFile.Tag.Pictures = new TagLib.IPicture[]
{
new TagLib.Picture(new TagLib.ByteVector((byte[])new System.Drawing.ImageConverter().ConvertTo(System.Drawing.Image.FromFile(jpgFilePath), typeof(byte[]))))
};

Dicominfo not giving all metadata

I have a dicom from a GE MRI scanner and there are a few pieces of information in the header I require (namely the relative position of the scan). I tried using info = dicominfo(filename) but, for some reason, this piece of information does not show up. I know that this information is saved, however. It might be a private data, but I'm not completely sure. If anyone has any information on how to resolve this issue that would be greatly appreciated.
Try using the dicomread function instead, it should be more versatile than dicominfo and it reads the information files too. If this doesn't work then it means that the information you are trying to obtain is not made available by GE.
Or use gdcm to dump the private GE header:
$ gdcmdump --pdb input.dcm