Camera and LookAt tags in KML files processed by the iPad's Google Earth - ios

My iPad app pops the Google Earth app via UIApplication:openURL: and passes it a URL of a file to display. The file displays fine, except for Camera and LookAt tags. It seems that the Camera tag is totally disregarded, while the LookAt is partially processed such that the point of view moves to a point close to the ground, much lower than the LookAt specification.
To debug this, I created two KMLs, copied from Google's documentation. The content is generated by a query on my server. The query's URL is passed to the Google Earth app from my app.
For comparison, I opened the same data on Google Earth running on a Mac. It works fine there.
This file is treated as a no-op by GE - it does not move its point of view at all:
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<Camera>
<longitude>-122.4783</longitude>
<latitude>37.8120</latitude>
<altitude>100</altitude>
<heading>90</heading>
<tilt>90</tilt>
<altitudeMode>absolute</altitudeMode>
</Camera>
</Placemark>
</Document>
</kml>
The following does move the point of view to the general area, but to a point which is exactly 500 meters above the ground, regardless of the range value.
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>Machu Picchu, Peru</name>
<LookAt>
<longitude>-72.503364</longitude>
<latitude>-13.209676</latitude>
<altitude>0</altitude>
<range>14794.882995</range>
<tilt>66.768762</tilt>
<heading>71.131493</heading>
</LookAt>
<styleUrl>#msn_icon12</styleUrl>
<Point>
<coordinates>-72.516244,-13.162806,0</coordinates>
</Point>
</Placemark>
</Document>
</kml>
I am using Google Earth 7.0.0.7455 on the iPad.
Any other tag that I passed to the GE app, such as for drawing polygons, works just fine. I'm only having trouble with Camera and LookAt.
I wonder if it's my bug, Google's, or both. If Google's, is there a workaround - any way of setting the camera?

Related

How to display pdf in a WebView in terms of UI and UX - iOS Swift

Brief about the app: The app parses html documents and load it in the app as a web view.
In the iOS app I like to show PDF files. There is a structure XML that would contain the whole structure.
Case 1: For a simple PDF file it would look like the following in the structure.xml
<node id="Nc13d37aa" node_id="82cd790d-e5f0-4ee6-a26c-a6e400af8541" type="publication" default="TEST_Pub" secured="false">
<language name="en-GB" path="X-BIKE-401/en-GB/publications/TEST_Pub-003.00.pdf">
<title>(Test-)Publication</title>
</language>
</node>
Case 2: In a more complex scenario one publication might contain a so called ATI's(Additional technical information) This would look like this:
<node id="Nd747c4dc" node_id="b4528fb8-c615-4b96-945d-a5af009325f2" type="publication" default="TEST_Pub_ATI" secured="false">
<language name="en-GB" path="X-BIKE-401/en-GB/publications/TEST_Pub_ATI-003.00.pdf">
<title>(Test-)Publication with ATI</title>
<atis>
<ati id="ati584a41ee" internal_id="af720ef4-5238-4fb4-ba8b-a5ae00debfae" code="Test_ATI" type="Service Letter" required="false" issuecode="Test_ATI_03" issuenumber="3" revisionnumber="0" href="X-BIKE-401\en-GB\ati\Test_ATI-003.00.pdf">(Test-)ATI</ati>
</atis>
</language>
</node>
The idea here is, that we have additional legacy documents accompanying a legacy publication. The idea here would be, that we show the normal legacy publication, but have an additional area in the view, that indicates the user, that there ARE ATIs, and a way for him to view the ATIs - but also get back to the original publication. An ATI is usually some information
Case 3: There is also the case, that one or many ATIs are mandatory.
This means, that the user needs to read & confirm those first, before he can read the actual publication. This will be like:
<node id="N5a3c00f" node_id="09fe8d7b-a95d-4da8-bf06-a5af00933ddc" type="publication" default="TEST_Pub_mATI" secured="false">
<language name="en-GB" path="X-BIKE-401/en-GB/publications/TEST_Pub_mATI-003.00.pdf">
<title>(Test-)Publication with MANDATORY ATI</title>
<atis>
<ati id="ati35c8ee0e" internal_id="60dfaa70-f017-44ea-9190-a5ae00df2494" code="Test_ATI_MAND1" type="Service Bulletin" required="true" issuecode="Test_mATI_03" issuenumber="3" revisionnumber="0" href="X-BIKE-401\en-GB\ati\Test_ATI_MAND1-003.00.pdf">(Test-)ATI1 (MANDATORY)</ati>
<ati id="atic771b1b6" internal_id="d1cffa4b-b1be-4bbb-8dc0-a743010cf246" code="Test_ATI_MAND2" type="Service Bulletin" required="true" issuecode="Test_mATI2_01" issuenumber="1" revisionnumber="0" href="X-BIKE-401\en-GB\ati\Test_ATI_MAND2-001.00.pdf">(Test-)ATI2 (MANDATORY)</ati>
</atis>
</language>
</node>
You can see, that two have the #required set to "true".
In this case we need to first show the first ATI, request the user to "confirm" somewhere that he read it. move on to the next required ATI and conform this as well. and once he has confirmed all the ATIs, he can view the publication itself.
Still he needs to be able to reopen the ATIs (similar to the previous point) and look them up again - without confirmation again.
The user needs to reconfirm, once the publication is closed.
Question: For case 2 & 3, how would this might look like? a mockup of it how would it be? Ideally a proposed solution best in terms of UI and UX.
I can suggest you this way , it may solve your question :
CASE 1 :
Simply Take a UIWebView and show PDF url link , then WebView will render it perfectly .
CASE 2 :
In case 2 you are first showing the case 1 where you show simple PDF and showing it by rendering the web view but then this PDF has extra information called ATI that we need to show this somehow on the web view. So for example a button that when you click on it it will show the extra information maybe in a pop up and then there should be a navigation back to the original PDF
CASE 3:
Use some Image Flipper library to show multiple pdf doc in which you can show some sort of info to acknowledge the user about there are more than one doc is there for navigation .
For Flipper follow this library : https://cocoapods.org/pods/DJKFlipper
Thanks.

Issue with FDF on different platforms PDFTron

I am facing an issue wherein I am unable to show annotations on my PDF on IOS device that are made from some other platforms e.g web, Windows or android. What is actually happening is if I am editing an already created annotation like an underline by changing the notes associated with it from my iOS device, then it is not reflecting on other platforms.
On further Investigation, I found that the PDF format generated by PDFTRON on iOS is different from the format generated by PDFTRON on any other platform. For example, I draw an underline annotation on a document from the web. The initial FDF received is as follows:
<squiggly subject="Squiggly" page="0" rect="275.93,656.703203,336.2084,665.759453" flags="print" name="0eabf5b2-77ab-4c04-3379-438e7a8fc714" title="testuser" date="D:20161027122930+05'30'" color="#FF0000" opacity="1" creationdate="D:20161027121425+05'30'" coords="275.93,665.76,336.21,665.76,275.93,656.7,336.21,656.7"><contents-richtext><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:spec="2.0.2" xfa:APIVersion="Acrobat:10.1.3"><p dir="ltr"><span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal">under_line</span></p></body></contents-richtext><contents>under_line</contents><popup flags="print,nozoom,norotate" page="0" rect="0,692,150,792" open="no"/></squiggly>
I have entered the text under_line in the notes initially. Now when I edit this annotation from the web (Changing the text from under_line to under_lines) , the resulting FDF is as follows:
<squiggly subject="Squiggly" page="0" rect="275.93,656.703203,336.2084,665.759453" flags="print" name="0eabf5b2-77ab-4c04-3379-438e7a8fc714" title="testuser" date="D:20161027122930+05'30'" color="#FF0000" opacity="1" creationdate="D:20161027121425+05'30'" coords="275.93,665.76,336.21,665.76,275.93,656.7,336.21,656.7"><contents-richtext><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:spec="2.0.2" xfa:APIVersion="Acrobat:10.1.3"><p dir="ltr"><span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal">under_lines</span></p></body></contents-richtext><contents>under_lines</contents><popup flags="print,nozoom,norotate" page="0" rect="0,692,150,792" open="no"/></squiggly>
The same annotation when edited from an iOS device produces the following FDF:
<squiggly subject="Squiggly" page="0" rect="275.93,656.703203,336.2084,665.759453" flags="print" name="0eabf5b2-77ab-4c04-3379-438e7a8fc714" title="testuser" date="D:20161027122930+05'30'" color="#FF0000" opacity="1" creationdate="D:20161027121425+05'30'" coords="275.93,665.76,336.21,665.76,275.93,656.7,336.21,656.7"><contents-richtext><body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:spec="2.0.2" xfa:APIVersion="Acrobat:10.1.3"><p dir="ltr"><span dir="ltr" style="font-size:10.0pt;text-align:left;color:#000000;font-weight:normal;font-style:normal">under_line</span></p></body></contents-richtext><contents>under_lines</contents><popup flags="print,nozoom,norotate" page="0" rect="0,692,150,792" open="no"/></squiggly>
Now you can see the difference. When I edit the text on the web, the text is changed at both points wherever it appears while when it is changed from the iOS device , the text is updated at only one place.
I believe this is causing a problem for me. How can I resolve this?
Annotation can actually have two Contents. The regular one, and a Rich Contents (essentially a minimal subset of HTML). The two are not guaranteed to be the same, which is the case here. One field got updated, the other didn't, as this actually depends on the specific PDF software used.
There is no difference between our different SDK's in this regards, so either you used two different files, or two different PDF readers. It sounds like on iOS used a 3rd party program.

Google Earth Exported KMZ file not including URL attribute

I am working on a project to import google earth projects into an iOS application. When I export the Google earth project as a KML (or KMZ) the attributes of a polygon are not exported. As an example :
<Placemark>
<name>Boko Haram Territory - Current</name>
<styleUrl>#transGreenPoly</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
12.70213131043391,11.21355437778219,0 12.76213125508861,11.11351379017489,0 12.80421246808032,10.88806232016611,0 12.81140564976727,10.88474047056056,0 12.82588348845796,10.87462437857204,0 12.97939393108183,10.83966554281775,0 13.01510820482933,10.83000208944705,0 13.07942019606773,10.81053246258202,0 13.14001872784027,10.79444004548873,0 13.17185030048722,10.79508081378772,0 13.18953386465979,10.79543528924301,0 13.20368048739284,10.79571825387904,0 13.2743290941496,10.80058614475469,0 13.30607760464441,10.80467645272363,0 13.33421396206393,10.8121582665838,0 13.35520437351619,10.82296520370417,0 13.37982059654026,10.83038365174029,0 13.40082694596582,10.8411976344037,0 13.41829814104605,10.85194186295296,0 13.43237918897503,10.85568440985296,0 13.50979264821408,10.87798951527388,0 13.51679936970521,10.88159220711055,0 13.53768612847479,10.89933537465694,0 13.55497533303261,10.92048068470509,0 13.56880021101213,10.93809651898877,0 13.57915675601498,10.95217987296234,0 13.66923758481358,11.06510360559719,0 13.6691768923637,11.06858393737642,0 13.65988323190011,11.19395197671864,0 13.65250883139019,11.40721510169971,0 13.65213241070391,11.42824958002745,0 13.64837915330032,11.43870451829143,0 13.64112270150342,11.44558811843954,0 13.33559955678247,11.5522146556532,0 12.97984978381745,11.48909495336167,0 12.82247610438195,11.36661781158571,0 12.70213131043391,11.21355437778219,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
That is the info for a polygon- but the attributes that are suppose to be here #transGreenPoly are not contained in the file and thus my KML parser does not have enough info to draw the poly in iOS. If I add manual the style like this:
<Style id="transGreenPoly">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7d00ff00</color>
</PolyStyle>
</Style>
It will work, but since we are dealing with dozens of poly that is not a solution. Is there a way to get the style URL from Google Earth

KMLViewer Apple's example not working

I've been searching for quite sometime an answer to my problem with no success.
So here it goes...
KMLViewer, Apple's example is not working in some cases.
After executing the README steps, i've tried to build up a route between Lisboa, Portugal and Porto, Portugal. And here the strangest thing happens. The annotations are built correctly, although the overlay (MKPolyline) does not, it only draws part of the route and it starts drawing in the middle of an "annotation".
What am i missing ?
You can try, Madrid - Barcelona, you have also the same issue.
Thanks in advance for spending sometime in this issue.
It looks like KMLViewer can only handle one LineString object per Placemark.
For the route you tried, Google is returning two LineString objects in the "Route" Placemark (the last one in the file). KMLViewer only displays the second (last) LineString segment.
Aside from updating the KMLViewer code to add support for multiple LineString objects per Placemark (which looks like a good exercise), you can try these two workarounds:
Combine the coordinates from the two LineString objects into one LineString. Change:
<Placemark>
<name>Route</name>
<description>some cdata stuff here</description>
<GeometryCollection>
<LineString><coordinates>coord1 … coordN</coordinates></LineString>
<LineString><coordinates>coordN+1 … coordK</coordinates></LineString>
</GeometryCollection>
<styleUrl>#roadStyle</styleUrl>
</Placemark>
To this:
<Placemark>
<name>Route</name>
<description>some cdata stuff here</description>
<GeometryCollection>
<LineString><coordinates>coord1 … coordN coordN+1 … coordK</coordinates></LineString>
</GeometryCollection>
<styleUrl>#roadStyle</styleUrl>
</Placemark>
The above might only make sense for routes (line segments) that are supposed to be continuous.
Another workaround is to split the "Route" Placemark into multiple placemarks (one for each LineString):
<Placemark>
<name>Route A</name>
<description>some cdata stuff here</description>
<GeometryCollection>
<LineString><coordinates>coord1 … coordN</coordinates></LineString>
</GeometryCollection>
<styleUrl>#roadStyle</styleUrl>
</Placemark>
<Placemark>
<name>Route B</name>
<description>some cdata stuff here</description>
<GeometryCollection>
<LineString><coordinates>coordN+1 … coordK</coordinates></LineString>
</GeometryCollection>
<styleUrl>#roadStyle</styleUrl>
</Placemark>
One issue with this is that the "description" which contains distance and time info will not match the split routes.
Yup. Thanks a lot for your fast response. I've discovered in the morning that the problem is with these tags together (close&open)
</coordinates></LineString><LineString><coordinates>
My plan:
Save the output from URL to a NSString, remove if exists the tags above, afterwards save to a file and send it to KMLParser.
I'll get back when i'm finished.
Again thanks a lot for your response.

How do I create kanji (Japanese letters) animations from SVG data in Objective-C?

I've seen several iPhone/iPad apps that show animated kanji. For those of you who are unfamiliar with kanji, stroke order is a very important part of kanji studying so if you are doing an app showing the animated stroke order is an essential part.
All the apps I've seen that do this, credit the KanjiVG project as their source for the stroke order data. After some research I found that the KanjiVG project gives you the data in SVG format encoded in XML.
Having never programmed graphics before (and being relatively new to iOS) I'm at a loss to where to keep looking for info.
I think I need to:
Parse the XML into SVG.
Render the SVG.
...but I'm not sure. For what I could see how this is done in the iPhone/iPad apps I bought, the animations all look surprisingly similar so there must be a common library that these guys are using that I'm failing to find (probably because I don't know exactly what I'm looking for!)
Any pointers that anyone can give me will be greatly appreciated.
Cheers!
This ended up being SO MUCH easier than I originally thought. The XML provided by the KanjiVG project not only contains all the kanji "parts" but the SVG data aswell!
So you get this:
<kanji midashi="会" id="4f1a">
<strokegr element="会">
<strokegr element="人" position="top" radical="general">
<stroke type="㇒" path="M52.25,14c0.25,2.28-0.52,3.59-1.8,5.62c-5.76,9.14-17.9,27-39.2,39.88"/>
<stroke type="㇏" path="M54.5,19.25c6.73,7.3,24.09,24.81,32.95,31.91c2.73,2.18,5.61,3.8,9.05,4.59"/>
</strokegr>
<strokegr element="云" position="bottom">
<strokegr element="二">
<stroke type="㇐" path="M37.36,50.16c1.64,0.34,4.04,0.36,4.98,0.25c6.79-0.79,14.29-1.91,19.66-2.4c1.56-0.14,3.25-0.39,4.66,0"/>
<stroke type="㇐" path="M23,65.98c2.12,0.52,4.25,0.64,7.01,0.3c13.77-1.71,30.99-3.66,46.35-3.74c3.04-0.02,4.87,0.14,6.4,0.29"/>
</strokegr>
<strokegr element="厶">
<stroke type="㇜" path="M47.16,66.38c0.62,1.65-0.03,2.93-0.92,4.28c-5.17,7.8-8.02,11.38-14.99,18.84c-2.11,2.25-1.5,4.18,2,3.75c7.35-0.91,28.19-5.83,40.16-7.95"/>
<stroke type="㇔" path="M66.62,77.39c4.52,3.23,11,12.73,13.06,18.82"/>
</strokegr>
</strokegr>
</strokegr>
</kanji>
And if you create your SVG file out of only the path attributes of the stroke nodes then you get a nice SVG drawing! Like this:
<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" version="1.1" baseProfile="full">
<path d="M52.25,14c0.25,2.28-0.52,3.59-1.8,5.62c-5.76,9.14-17.9,27-39.2,39.88" style="fill:none;stroke:black;stroke-width:2" />
<path d="M54.5,19.25c6.73,7.3,24.09,24.81,32.95,31.91c2.73,2.18,5.61,3.8,9.05,4.59" style="fill:none;stroke:black;stroke-width:2" />
<path d="M37.36,50.16c1.64,0.34,4.04,0.36,4.98,0.25c6.79-0.79,14.29-1.91,19.66-2.4c1.56-0.14,3.25-0.39,4.66,0" style="fill:none;stroke:black;stroke-width:2" />
<path d="M23,65.98c2.12,0.52,4.25,0.64,7.01,0.3c13.77-1.71,30.99-3.66,46.35-3.74c3.04-0.02,4.87,0.14,6.4,0.29" style="fill:none;stroke:black;stroke-width:2" />
<path d="M47.16,66.38c0.62,1.65-0.03,2.93-0.92,4.28c-5.17,7.8-8.02,11.38-14.99,18.84c-2.11,2.25-1.5,4.18,2,3.75c7.35-0.91,28.19-5.83,40.16-7.95" style="fill:none;stroke:black;stroke-width:2" />
<path d="M66.62,77.39c4.52,3.23,11,12.73,13.06,18.82" style="fill:none;stroke:black;stroke-width:2" />
</svg>
Copy the above SVG XML and paste it into a plain text file. Name this file something that ends in .svg and drag it into Firefox. There it is, a graphic representation of the Kanji!
So now that I have all the "raw" SVG info it's just a matter of finding the appropriate SVG renderer.
I wrote a javascript renderer for KanjiVG data a few years back that animates stokes. It might serve as a working example for you or even a solution depending on what you want to do.
The approach I took was to break the KanjiVG stroke data into a set of javascript data files, write my own code for drawing cubic and quadratic curves and then write an event queue function that takes kanji, looks them up and enqueues the rendering of each stroke in an array.
The source is not obfuscated in any way and contains the odd comment. Best of luck!
I'm interested in this as well. Have you gotten any further?
I am able to display the kanji from an svg file this way by creating a UIwebview.
In this example my file is k1.svg, and the image was drawn after hitting a button (the sender). I'm working on getting it animated now
-(void) doSVG:(id)sender {
NSString *filePath = [[NSBundle mainBundle]
pathForResource:#"k1" ofType:#"svg"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
NSURLRequest *req = [NSURLRequest requestWithURL:fileURL];
//[kanjiView setScalesPageToFit:YES];
[yourWebView loadRequest:req];
}
My question to you is, have you found an easy way to get all the svg info out of the xml file from kanjiVG?
There is no need to translate the KanjiVG data into SVG data, because it already is SVG data. From their wiki:
Any KanjiVG file is 100% SVG-compliant and can be opened by one's favorite SVG viewer/editor to be seen as-is.
The reason the data looks so different is that they're using SVG Groups to store extra information. But the KanjiVG data itself should still render fine using any standards-compliant SVG library.
You can also consider "AnimCJK project" (https://github.com/parsimonhi/animCJK) as source for kanji svg data. The principle is slightly different from "KanjiVG project" (http://kanjivg.tagaini.net/) and the underlying font is different (kaisho style), but extracting the path data is simple. Using a regex such as #<path[^>]+id="z[0-9]+d[0-9]+"[^>]+d="([^"]+)"[^>]+># does the job.

Resources