Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus
Accepted Solution

How to save Polyline map features to an SQL database?

I've got an app with a mapview and I'm looking to add the polyline feature, but I'm a little confused as to how I would add all the geographic points into my database?  Do they all get pasted and appended into one column?  Or do I need to keep adding columns for each set of points?

 

Right now my DB is setup to save one point location and I'm wondering if I have to make any drastic changes to accomodate Polylines.

 

All help is appreciated in will be liked and marked as solved if it solves the question.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to save Polyline map features to an SQL database?

you could use the existing table, but you would need a reference to group the locations.
you can modify a sqllite database using the alter table syntax, if needed.

if you need all locations of a single polyline you could query by id, like select * from locations where polyLineId = '3' or the like.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: How to save Polyline map features to an SQL database?

[ Edited ]

Cheeky,

 

I didn't even think about writing a PolyLineID to group the points by.  How would the function know to set PolyLineID = 3 instead.  Could I query the db to search for the max under column PolyLineID and then take that number +1 ?  Is this even possible?

 

I'm also wondering how I'd be able to fetch the data to be used to display a polyline afterwards?

 

I could probably do something like select polyLineID from locations group by polylineID for the main listview to show each set as one object.  But for actually pulling that information, correct me if I'm wrong, I'd have to pull all the Lon/Lats for each PolyLineID = 3 and pull them based on the record ID number so that they are ordered correctly.  Right?

 

 

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to save Polyline map features to an SQL database?

i don't know exactly what a polyline is, but i assume it is an ordered list of gps coordinates (please correct me if i am wrong)

you start with the list and want to store it.
to do that you first create an entry in your reference table, like "insert into poly_references (name) value ('name').
take the id from the insert QSqlQuery.lastInsertId().toInt()

Now you have the reference id.
In your polyline table, which has a column referenceId, you insert all the polyline entries with this id.

To retrieve the whole thing you first query your reference table and retrieve name and id. with the id you query the polyline table.

I use the firefox plugin sqlitemanager to create and experiment with sqlite queries and databases, i can highly recommend it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 358
Registered: ‎04-13-2013
My Device: Z10
My Carrier: Telus

Re: How to save Polyline map features to an SQL database?

[ Edited ]

Awesome.  Thanks for the insights.  FYI, PolyLine is the feature in maps that draws a line on a map based on movement.  Sometimes I have a hard time thinking out the logic.  Will check out the firefox plugin.