I'm thinking about creating a location-aware iPhone app that could work offline by coming packaged with a list of points of interest (POIs). The app would read the user's current location from CoreLocation and produce a list of the POIs in order of proximity to the user's current location.
I need two basic geospatial functions to get this application off the ground. The first is a function that tests if a point (the user's current location) lies within certain geospatial boundaries. The second is a function that can give me the distance between two lat/lon points. I would use the second function to sort the list of POIs by proximity to the user's current location.
I understand that this problem area is well traveled and there are open-source options. The leading candidate (that I know of) is the GEOS C++ library. The way I imagine I would use this is by compiling GEOS as a static library (and linking as a project dependency, as you do to include the three20 library.)
My question is:
What is the best way to get the two necessary functions into my application.
If the best answer to question 1 is compiling GEOS as a static library and linking it to my project, could anyone who has done this before offer some pointers? I'm a novice at compilation, static library building, etc. I would love to see some example code or tutorials on how to get GEOS compiled and included in a project with a trivial example usage.
Ok, it took me some time but now I think that I'm properly able to build the static libs or GEOS for iPhone (x86 and ARM for both the simulator and the real device) : libgeos.a and libgeos_c.a : the implementation and its api.
You can get the binaires there (for GEOS version 3.1.1, this is not the very last one) :
http://bit.ly/aTKsI6
(there are some other binaries there, the rest is for spatialite)
The job has been mostly achieved by understanding the way cross compilation is done via .sh scripts. This blog is a must see for that : http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
For distance between points, see CLLocation's getDistanceFrom: method.
I'm not sure what you mean by geospatial boundaries, but if you mean you have a rectangle defining a location, you can convert it to a CGRect, offset the latitude and longitude of all of your points by 90 and 180 respectively to make sure you don't have negative numbers, convert your CLLocation objects to CGPoints, then use CGRectContainsPoint to figure out if your location is within that rectangle.
All of the described functions are part of the standard iPhone SDK.
Related
I'm trying to learn to write Hardware Abstraction Layer (HAL).
Here's the path I've taken so far, please correct me if I'm off in any step.
Downloaded AOSP and built it successfully (86%)
Located Vehicle Hal Support Library
Located android.hardware.automotive.vehicle C++ code.
Things I've attempted after that the steps below without succeeding to get those above classes recognized.
Import android.hardware.automotive.vehicle classes in Android Studio for a typical Android App that targets 29 Api Level.
Adding meta tag of android.car app
Copy/Pasting all source code under AOSP /packages/services/Car/
Partially contemplated adding android.hardware.automotive.vehicle#2.0.so Library and trying to access it through JNI (Not so sure about this one).
Please orient me, I see some repositories on github not doing anything special and somehow they're able to import the package in a java class like this.
import android.hardware.automotive.vehicle.V2_0.VehicleHwKeyInputAction;
import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
Here
how on earth do they get access to those classes?
Thanks
Vehicle HAL is not meant to be accessed directly from apps. Car Service does that for you.
You have couple options depending on what you're actually trying to accomplish:
Learn to write HAL services - it's like writing a driver for a given hardware (in this case, something that provides car data to Car Service).
Learn to write HAL clients - try modifying EmbeddedKitchenSink app first. Please note you need to build it with AOSP and not in AmdroidStudio since this is a system app (and regular apps doesn't have access to the HAL)
Learn Vehicle APIs - that's what you need car lib for. Details on how to use it: https://stackoverflow.com/a/63321234/14759774
I am getting really desperate here. I working with Xcode, trying to implement some OpenGL stuff on the iPhone. I have to write a Shader for Phong-Lighting. I got as far as declaring my geometry (vertices, indices, calculating etc.) and passing the respective arguments as attributes to the shader (written in GLSL). Using these attributes works fine, some really basic shader programs compile correctly and give the expected output.
Now I'm trying to start with some more advanced calculations, for which I need to use some of the built-in attributes of GLSL, namely i.e. the "gl_NormalMatrix", but whenever I try that, the program crashes and I get an "ERROR: 0:3: Use of undeclared identifier 'gl_NormalMatrix'".
It happens identically whenever use any of the built-in attributes such as gl_Vertex, gl_Normal etc.
Are these attributes not available in GLSL on the iPhone or am I missing something? Maybe I haven't fully understood how this works. As mentioned, passing my own vertex attributes into the shader works fine, and I am also wondering how the program should "know" the correct values "on its own" - so the whole concept of built-in attributes is still a bit confusing to me. But whenever I try to run some shaders I found online to see if something happens, I get these errors thrown, even though everyone else seems to use built-in attributes extensively when writing shaders.
I really hope someone here can shed some light on this. Thousand thanks in advance!
Julia
Those attributes aren't available in GL ES, whether on the iPhone or elsewhere. And the same goes for WebGL. You need to write your own matrix code, or use GLKit if you're supporting only iOS 5+, and supply attributes for yourself. See Kronos' reference card for an incredibly concise summary of what made it into ES 2.0 — amongst other things it lists all the available built-in special variables as:
gl_Position
gl_PointSize
gl_FragCoord
gl_FrontFacing
gl_PointCoord
gl_FragColor
gl_FragData[n]
GLKit's maths stuff is really good because it inlines and uses the ARM's NEON SIMD unit. I consider it a sufficient reason to specify iOS 5 as a minimum in all new GL projects.
I am following the steps in the below link to locate my location using GPS (point on the map), I got an idea that requires to draw a line between multipule points (ex. a line from point 1 to point 2 to point X .. etc).
What are my options in doing so?
http://www.codeproject.com/KB/windows-phone-7/simplegps.aspx
thanks,
You could consider using a thirdparty library from ESRI. Look for the ESRI Silverlight and Windows Phone SDK. You will need to create an account on the Esri site, but it's for free (and so is the sdk). It has ton of options that the current lib from microsoft doesnt have.
I am using following url to get driving directions between two locations.
NSString* apiUrlStr = [NSString stringWithFormat:#"http://maps.google.com/maps?output=dragdir&saddr=%#&daddr=%#", saddr, daddr];
What changes need to be done in above query to get directions for bicycle, walking or public transport and corresponding distance, time required between two places?
Thanks in advance for any help.
You must use the "dirflg=?" parameter, where "?" can be:
dirflg Route type.
dirflg=h Switches on "Avoid Highways" route finding mode.
dirflg=t Switches on "Avoid Tolls" route finding mode.
dirflg=r Switches on "Public Transit" - only works in some areas. Can also set date and time info described below.
dirflg=w Switches to walking directions - still in beta.
dirflg=b Switches to biking directions - only works in some areas and still in beta.
There are many other params available, read the Google Maps Parameters doc, but of course not all of them are supported by the Maps native API (which is updated at every iOS release). Is up to you to test them as the official Apple doc is not always up to date with all features.
In android we have the R class that stands for Resources, where we have references to all of our resources and we can easily access them in the code. Is there an equivalent in iOS? I have this doubt because, I want to be able to define multiple files with different values, for instance:
DefaultValuesForViewController1
DefaultValuesForViewController2
Besides creating plist, is there another way (faster and easier like R)?
There is no R class equivalent access method.
In Android, the R class represents access to resources that are consolidated into a native format. iPhone does not do this. Instead, resource files are just copied as is into the application bundle and must be found & opened as such.
You could create a class to store all of your data for the app. iOS generally likes the app to run lean and mean, so only storing your objects for as long as you need them, releasing them as soon as you are done with them. If you were to store everything globally, it would add some overhead, but assuming you don't have a ton of information, it shouldn't be an issue.
There is no equivalent for this in iOS apps. All you get is files that you can enumerate using standard file I/O.
However, you can emulate it partially. Here's a simple demo on GitHub
You can find that SwiftGen(e.g. Tuist used it) can be used as an alternative for autogenerated R.java file on Android
Two point
it is third party source
you have to manually run script after changing your resources