From b4198a7a79aef50a440a6796618e1e7e67c5da78 Mon Sep 17 00:00:00 2001 From: chanywa Date: Tue, 27 Dec 2016 12:52:23 +0900 Subject: [PATCH] Tizen.Maps Setup Change-Id: I4f8b094487f3d7260df3fb0c64bd4d7c9e2e2b6b --- .gitattributes | 63 +++ .gitignore | 7 + LICENSE | 202 +++++++++ packaging/csapi-maps.manifest | 5 + packaging/csapi-maps.spec | 72 +++ src/Tizen.Maps/Interop/Interop.Address.cs | 125 ++++++ src/Tizen.Maps/Interop/Interop.Area.cs | 48 ++ src/Tizen.Maps/Interop/Interop.Coordinates.cs | 82 ++++ src/Tizen.Maps/Interop/Interop.ErrorCode.cs | 106 +++++ src/Tizen.Maps/Interop/Interop.Libraries.cs | 23 + src/Tizen.Maps/Interop/Interop.Place.Attribute.cs | 44 ++ src/Tizen.Maps/Interop/Interop.Place.Category.cs | 56 +++ src/Tizen.Maps/Interop/Interop.Place.Contact.cs | 44 ++ src/Tizen.Maps/Interop/Interop.Place.Editorial.cs | 44 ++ src/Tizen.Maps/Interop/Interop.Place.Filter.cs | 74 ++++ src/Tizen.Maps/Interop/Interop.Place.Image.cs | 53 +++ .../Interop/Interop.Place.Link.Object.cs | 47 ++ src/Tizen.Maps/Interop/Interop.Place.Media.cs | 44 ++ src/Tizen.Maps/Interop/Interop.Place.Rating.cs | 41 ++ src/Tizen.Maps/Interop/Interop.Place.Review.cs | 56 +++ src/Tizen.Maps/Interop/Interop.Place.cs | 118 +++++ src/Tizen.Maps/Interop/Interop.Preference.cs | 155 +++++++ src/Tizen.Maps/Interop/Interop.Route.Maneuver.cs | 91 ++++ src/Tizen.Maps/Interop/Interop.Route.Segment.cs | 62 +++ src/Tizen.Maps/Interop/Interop.Route.cs | 77 ++++ src/Tizen.Maps/Interop/Interop.SafeMapsHandle.cs | 54 +++ src/Tizen.Maps/Interop/Interop.Service.cs | 167 +++++++ src/Tizen.Maps/Interop/Interop.View.Event.Data.cs | 94 ++++ src/Tizen.Maps/Interop/Interop.View.Object.cs | 155 +++++++ src/Tizen.Maps/Interop/Interop.View.Snapshot.cs | 32 ++ src/Tizen.Maps/Interop/Interop.View.cs | 168 +++++++ src/Tizen.Maps/Properties/AssemblyInfo.cs | 35 ++ src/Tizen.Maps/Tizen.Maps.Net45.csproj | 137 ++++++ src/Tizen.Maps/Tizen.Maps.Net45.project.json | 17 + src/Tizen.Maps/Tizen.Maps.csproj | 154 +++++++ src/Tizen.Maps/Tizen.Maps.nuspec | 16 + src/Tizen.Maps/Tizen.Maps.project.json | 15 + src/Tizen.Maps/Tizen.Maps.snk | Bin 0 -> 596 bytes src/Tizen.Maps/Tizen.Maps/Area.cs | 77 ++++ src/Tizen.Maps/Tizen.Maps/Direction.cs | 61 +++ src/Tizen.Maps/Tizen.Maps/DistanceUnit.cs | 41 ++ src/Tizen.Maps/Tizen.Maps/GeocodePreference.cs | 95 ++++ src/Tizen.Maps/Tizen.Maps/GeocodeRequest.cs | 99 +++++ src/Tizen.Maps/Tizen.Maps/Geocoordinates.cs | 75 ++++ src/Tizen.Maps/Tizen.Maps/GeocoordinatesList.cs | 77 ++++ src/Tizen.Maps/Tizen.Maps/GestureType.cs | 33 ++ src/Tizen.Maps/Tizen.Maps/MapGestureEventArgs.cs | 62 +++ src/Tizen.Maps/Tizen.Maps/MapObject.cs | 70 +++ src/Tizen.Maps/Tizen.Maps/MapObjectEventArgs.cs | 54 +++ src/Tizen.Maps/Tizen.Maps/MapObjectType.cs | 26 ++ src/Tizen.Maps/Tizen.Maps/MapService.cs | 330 ++++++++++++++ src/Tizen.Maps/Tizen.Maps/MapServiceRequest.cs | 85 ++++ src/Tizen.Maps/Tizen.Maps/MapTypes.cs | 26 ++ src/Tizen.Maps/Tizen.Maps/MapView.cs | 492 +++++++++++++++++++++ src/Tizen.Maps/Tizen.Maps/Marker.cs | 143 ++++++ .../Tizen.Maps/MultiReverseGeocodeRequest.cs | 66 +++ src/Tizen.Maps/Tizen.Maps/Overlay.cs | 127 ++++++ src/Tizen.Maps/Tizen.Maps/Place.cs | 344 ++++++++++++++ src/Tizen.Maps/Tizen.Maps/PlaceAddress.cs | 296 +++++++++++++ src/Tizen.Maps/Tizen.Maps/PlaceAddressList.cs | 76 ++++ src/Tizen.Maps/Tizen.Maps/PlaceAttribute.cs | 58 +++ src/Tizen.Maps/Tizen.Maps/PlaceCategory.cs | 119 +++++ src/Tizen.Maps/Tizen.Maps/PlaceContact.cs | 59 +++ src/Tizen.Maps/Tizen.Maps/PlaceEditorial.cs | 62 +++ src/Tizen.Maps/Tizen.Maps/PlaceFilter.cs | 145 ++++++ src/Tizen.Maps/Tizen.Maps/PlaceImage.cs | 93 ++++ src/Tizen.Maps/Tizen.Maps/PlaceLink.cs | 69 +++ src/Tizen.Maps/Tizen.Maps/PlaceList.cs | 66 +++ src/Tizen.Maps/Tizen.Maps/PlaceMedia.cs | 67 +++ src/Tizen.Maps/Tizen.Maps/PlaceRating.cs | 50 +++ src/Tizen.Maps/Tizen.Maps/PlaceReview.cs | 109 +++++ src/Tizen.Maps/Tizen.Maps/PlaceSearchPreference.cs | 165 +++++++ src/Tizen.Maps/Tizen.Maps/PlaceSearchRequest.cs | 101 +++++ src/Tizen.Maps/Tizen.Maps/Polygon.cs | 102 +++++ src/Tizen.Maps/Tizen.Maps/Polyline.cs | 115 +++++ src/Tizen.Maps/Tizen.Maps/ReverseGeocodeRequest.cs | 64 +++ src/Tizen.Maps/Tizen.Maps/Route.cs | 218 +++++++++ src/Tizen.Maps/Tizen.Maps/RouteFeature.cs | 69 +++ src/Tizen.Maps/Tizen.Maps/RouteFeatureWeight.cs | 45 ++ src/Tizen.Maps/Tizen.Maps/RouteManeuver.cs | 120 +++++ src/Tizen.Maps/Tizen.Maps/RouteOptimization.cs | 49 ++ src/Tizen.Maps/Tizen.Maps/RouteSearchPreference.cs | 196 ++++++++ src/Tizen.Maps/Tizen.Maps/RouteSearchRequest.cs | 120 +++++ src/Tizen.Maps/Tizen.Maps/RouteSegment.cs | 124 ++++++ src/Tizen.Maps/Tizen.Maps/ServiceData.cs | 95 ++++ src/Tizen.Maps/Tizen.Maps/ServiceRequestType.cs | 89 ++++ src/Tizen.Maps/Tizen.Maps/SnapshotType.cs | 33 ++ src/Tizen.Maps/Tizen.Maps/TransportMode.cs | 45 ++ src/Tizen.Maps/Tizen.Maps/TurnInstruction.cs | 85 ++++ 89 files changed, 8270 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 packaging/csapi-maps.manifest create mode 100644 packaging/csapi-maps.spec create mode 100755 src/Tizen.Maps/Interop/Interop.Address.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Area.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Coordinates.cs create mode 100755 src/Tizen.Maps/Interop/Interop.ErrorCode.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Libraries.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Attribute.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Category.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Contact.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Editorial.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Filter.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Image.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Link.Object.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Media.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Rating.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.Review.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Place.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Preference.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Route.Maneuver.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Route.Segment.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Route.cs create mode 100755 src/Tizen.Maps/Interop/Interop.SafeMapsHandle.cs create mode 100755 src/Tizen.Maps/Interop/Interop.Service.cs create mode 100755 src/Tizen.Maps/Interop/Interop.View.Event.Data.cs create mode 100755 src/Tizen.Maps/Interop/Interop.View.Object.cs create mode 100755 src/Tizen.Maps/Interop/Interop.View.Snapshot.cs create mode 100755 src/Tizen.Maps/Interop/Interop.View.cs create mode 100755 src/Tizen.Maps/Properties/AssemblyInfo.cs create mode 100755 src/Tizen.Maps/Tizen.Maps.Net45.csproj create mode 100644 src/Tizen.Maps/Tizen.Maps.Net45.project.json create mode 100755 src/Tizen.Maps/Tizen.Maps.csproj create mode 100644 src/Tizen.Maps/Tizen.Maps.nuspec create mode 100755 src/Tizen.Maps/Tizen.Maps.project.json create mode 100755 src/Tizen.Maps/Tizen.Maps.snk create mode 100755 src/Tizen.Maps/Tizen.Maps/Area.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Direction.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/DistanceUnit.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/GeocodePreference.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/GeocodeRequest.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Geocoordinates.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/GeocoordinatesList.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/GestureType.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapGestureEventArgs.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapObject.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapObjectEventArgs.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapObjectType.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapService.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapServiceRequest.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapTypes.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MapView.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Marker.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/MultiReverseGeocodeRequest.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Overlay.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Place.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceAddress.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceAddressList.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceAttribute.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceCategory.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceContact.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceEditorial.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceFilter.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceImage.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceLink.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceList.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceMedia.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceRating.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceReview.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceSearchPreference.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/PlaceSearchRequest.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Polygon.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Polyline.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/ReverseGeocodeRequest.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/Route.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteFeature.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteFeatureWeight.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteManeuver.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteOptimization.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteSearchPreference.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteSearchRequest.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/RouteSegment.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/ServiceData.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/ServiceRequestType.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/SnapshotType.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/TransportMode.cs create mode 100755 src/Tizen.Maps/Tizen.Maps/TurnInstruction.cs diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5896c16 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..46619d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +bin/ +obj/ +*.exe +*.dll +*.csproj.user +*.lock.json +.vs/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/packaging/csapi-maps.manifest b/packaging/csapi-maps.manifest new file mode 100644 index 0000000..75b0fa5 --- /dev/null +++ b/packaging/csapi-maps.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/csapi-maps.spec b/packaging/csapi-maps.spec new file mode 100644 index 0000000..20877d8 --- /dev/null +++ b/packaging/csapi-maps.spec @@ -0,0 +1,72 @@ +%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework} + +%if 0%{?tizen_build_devel_mode} +%define BUILDCONF Debug +%else +%define BUILDCONF Release +%endif + +Name: csapi-maps +Summary: Tizen Map Service API for C# +Version: 1.0.1 +Release: 1 +Group: Development/Libraries +License: Apache-2.0 +URL: https://www.tizen.org +Source0: %{name}-%{version}.tar.gz +Source1: %{name}.manifest + +BuildRequires: mono-compiler +BuildRequires: mono-devel + +BuildRequires: dotnet-build-tools +BuildRequires: csapi-tizen-nuget +BuildRequires: elm-sharp-nuget + +%description +Tizen Map Service API for C# + +%prep +%setup -q +cp %{SOURCE1} . + +%define Assemblies Tizen.Maps + +%build +for ASM in %{Assemblies}; do +# NuGet Restore +find $ASM/*.project.json -exec nuget restore {} \; +# Build +find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \; +# NuGet Pack +nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF} +done + +%install +# Runtime Binary +mkdir -p %{buildroot}%{dotnet_assembly_path} +for ASM in %{Assemblies}; do +%if 0%{?_with_corefx} + install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path} +%else + install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path} +%endif +done +# NuGet +mkdir -p %{buildroot}/nuget +install -p -m 644 *.nupkg %{buildroot}/nuget + +%files +%manifest %{name}.manifest +%license LICENSE +%attr(644,root,root) %{dotnet_assembly_path}/*.dll + +%package nuget +Summary: NuGet package for %{name} +Group: Development/Libraries + +%description nuget +NuGet package for %{name} + +%files nuget +/nuget/*.nupkg diff --git a/src/Tizen.Maps/Interop/Interop.Address.cs b/src/Tizen.Maps/Interop/Interop.Address.cs new file mode 100755 index 0000000..4882035 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Address.cs @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Address + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool AddressCallback(int index, IntPtr /* maps_address_h */ addressHandle, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_create")] + internal static extern ErrorCode Create(out IntPtr /* maps_address_h */ address); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_address_h */ address); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_clone")] + internal static extern ErrorCode Clone(IntPtr /* maps_address_h */ origin, out IntPtr /* maps_address_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_building_number")] + internal static extern ErrorCode GetBuildingNumber(AddressHandle /* maps_address_h */ address, out string buildingNumber); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_street")] + internal static extern ErrorCode GetStreet(AddressHandle /* maps_address_h */ address, out string street); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_district")] + internal static extern ErrorCode GetDistrict(AddressHandle /* maps_address_h */ address, out string district); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_city")] + internal static extern ErrorCode GetCity(AddressHandle /* maps_address_h */ address, out string city); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_state")] + internal static extern ErrorCode GetState(AddressHandle /* maps_address_h */ address, out string state); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_country")] + internal static extern ErrorCode GetCountry(AddressHandle /* maps_address_h */ address, out string country); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_country_code")] + internal static extern ErrorCode GetCountryCode(AddressHandle /* maps_address_h */ address, out string countryCode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_county")] + internal static extern ErrorCode GetCounty(AddressHandle /* maps_address_h */ address, out string county); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_postal_code")] + internal static extern ErrorCode GetPostalCode(AddressHandle /* maps_address_h */ address, out string postalCode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_get_freetext")] + internal static extern ErrorCode GetFreetext(AddressHandle /* maps_address_h */ address, out string freetext); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_building_number")] + internal static extern ErrorCode SetBuildingNumber(AddressHandle /* maps_address_h */ address, string buildingNumber); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_street")] + internal static extern ErrorCode SetStreet(AddressHandle /* maps_address_h */ address, string street); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_district")] + internal static extern ErrorCode SetDistrict(AddressHandle /* maps_address_h */ address, string district); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_city")] + internal static extern ErrorCode SetCity(AddressHandle /* maps_address_h */ address, string city); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_state")] + internal static extern ErrorCode SetState(AddressHandle /* maps_address_h */ address, string state); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_country")] + internal static extern ErrorCode SetCountry(AddressHandle /* maps_address_h */ address, string country); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_country_code")] + internal static extern ErrorCode SetCountryCode(AddressHandle /* maps_address_h */ address, string countryCode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_county")] + internal static extern ErrorCode SetCounty(AddressHandle /* maps_address_h */ address, string county); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_postal_code")] + internal static extern ErrorCode SetPostalCode(AddressHandle /* maps_address_h */ address, string postalCode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_set_freetext")] + internal static extern ErrorCode SetFreetext(AddressHandle /* maps_address_h */ address, string freetext); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_list_create")] + internal static extern ErrorCode ListCreate(out IntPtr /* maps_address_list_h */ addressList); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_list_append")] + internal static extern ErrorCode ListAppend(AddressListHandle /* maps_address_list_h */ addressList, AddressHandle /* maps_address_h */ address); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_list_remove")] + internal static extern ErrorCode ListRemove(AddressListHandle /* maps_address_list_h */ addressList, AddressHandle /* maps_address_h */ address); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_list_get_length")] + internal static extern ErrorCode ListGetLength(AddressListHandle /* maps_address_list_h */ addressList, out int length); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_list_foreach")] + internal static extern ErrorCode ListForeach(AddressListHandle /* maps_address_list_h */ addressList, AddressCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_address_list_destroy")] + internal static extern ErrorCode ListDestroy(IntPtr /* maps_address_list_h */ addressList); + } + + internal class AddressHandle : SafeMapsHandle + { + public AddressHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Address.Destroy; } + } + + + internal class AddressListHandle : SafeMapsHandle + { + public AddressListHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Address.ListDestroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Area.cs b/src/Tizen.Maps/Interop/Interop.Area.cs new file mode 100755 index 0000000..6ba654e --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Area.cs @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum AreaType + { + None, // MAPS_AREA_NONE + Rectangle, // MAPS_AREA_RECTANGLE + Circle, // MAPS_AREA_CIRCLE + } + + internal static partial class Area + { + [DllImport(Libraries.MapService, EntryPoint = "maps_area_create_rectangle")] + internal static extern ErrorCode CreateRectangle(CoordinatesHandle /* maps_coordinates_h */ topLeft, CoordinatesHandle /* maps_coordinates_h */ bottomRight, out IntPtr /* maps_area_h */ area); + + [DllImport(Libraries.MapService, EntryPoint = "maps_area_create_circle")] + internal static extern ErrorCode CreateCircle(CoordinatesHandle /* maps_coordinates_h */ center, double radius, out IntPtr /* maps_area_h */ area); + + [DllImport(Libraries.MapService, EntryPoint = "maps_area_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_area_h */ area); + + [DllImport(Libraries.MapService, EntryPoint = "maps_area_clone")] + internal static extern ErrorCode Clone(AreaHandle /* maps_area_h */ origin, out IntPtr /* maps_area_h */ cloned); + } + + internal class AreaHandle : SafeMapsHandle + { + public AreaHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Area.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Coordinates.cs b/src/Tizen.Maps/Interop/Interop.Coordinates.cs new file mode 100755 index 0000000..5f975ba --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Coordinates.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Coordinates + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool CoordinatesCallback(int index, IntPtr /* maps_coordinates_h */ coordinates, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_create")] + internal static extern ErrorCode Create(double latitude, double longitude, out IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_clone")] + internal static extern ErrorCode Clone(IntPtr /* maps_coordinates_h */ origin, out IntPtr /* maps_coordinates_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_get_latitude")] + internal static extern ErrorCode GetLatitude(CoordinatesHandle /* maps_coordinates_h */ coordinates, out double latitude); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_get_longitude")] + internal static extern ErrorCode GetLongitude(CoordinatesHandle /* maps_coordinates_h */ coordinates, out double longitude); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_get_latitude_longitude")] + internal static extern ErrorCode GetLatitudeLongitude(CoordinatesHandle /* maps_coordinates_h */ coordinates, out double latitude, out double longitude); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_set_latitude")] + internal static extern ErrorCode SetLatitude(CoordinatesHandle /* maps_coordinates_h */ coordinates, double latitude); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_set_longitude")] + internal static extern ErrorCode SetLongitude(CoordinatesHandle /* maps_coordinates_h */ coordinates, double longitude); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_set_latitude_longitude")] + internal static extern ErrorCode SetLatitudeLongitude(CoordinatesHandle /* maps_coordinates_h */ coordinates, double latitude, double longitude); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_list_create")] + internal static extern ErrorCode ListCreate(out IntPtr /* maps_coordinates_list_h */ coordinatesList); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_list_destroy")] + internal static extern ErrorCode ListDestroy(IntPtr /* maps_coordinates_list_h */ coordinatesList); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_list_append")] + internal static extern ErrorCode ListAppend(CoordinatesListHandle /* maps_coordinates_list_h */ coordinatesList, IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_list_remove")] + internal static extern ErrorCode ListRemove(CoordinatesListHandle /* maps_coordinates_list_h */ coordinatesList, CoordinatesHandle /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_list_get_length")] + internal static extern ErrorCode ListGetLength(CoordinatesListHandle /* maps_coordinates_list_h */ coordinatesList, out int length); + + [DllImport(Libraries.MapService, EntryPoint = "maps_coordinates_list_foreach")] + internal static extern ErrorCode ListForeach(CoordinatesListHandle /* maps_coordinates_list_h */ coordinatesList, CoordinatesCallback callback, IntPtr /* void */ userData); + } + + internal class CoordinatesHandle : SafeMapsHandle + { + public CoordinatesHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Coordinates.Destroy; } + } + + internal class CoordinatesListHandle : SafeMapsHandle + { + public CoordinatesListHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Coordinates.ListDestroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.ErrorCode.cs b/src/Tizen.Maps/Interop/Interop.ErrorCode.cs new file mode 100755 index 0000000..1b90512 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.ErrorCode.cs @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.CompilerServices; +using Tizen; + +internal static partial class Interop +{ + internal enum ErrorCode + { + None = Tizen.Internals.Errors.ErrorCode.None, + PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, + InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, + NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, + ConnectionTimeOut = Tizen.Internals.Errors.ErrorCode.ConnectionTimeout, + NetworkUnreachable = Tizen.Internals.Errors.ErrorCode.NetworkUnreachable, + InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, + KeyNotAvailable = Tizen.Internals.Errors.ErrorCode.KeyNotAvailable, + ResourceBusy = Tizen.Internals.Errors.ErrorCode.ResourceBusy, + Canceled = Tizen.Internals.Errors.ErrorCode.Canceled, + Unknown = Tizen.Internals.Errors.ErrorCode.Unknown, + ServiceNotAvailable = -0x02C20000 | 0x01, // MAPS_ERROR_SERVICE_NOT_AVAILABLE + NotFound = -0x02C20000 | 0x02, // MAPS_ERROR_NOT_FOUND + } +} + +internal static class ErrorCodeExtensions +{ + private const string LogTag = "Tizen.Maps"; + + internal static bool IsSuccess(this Interop.ErrorCode err) + { + return err == Interop.ErrorCode.None; + } + + internal static bool IsFailed(this Interop.ErrorCode err) + { + return !err.IsSuccess(); + } + + /// + /// Utility method to check for error, returns false if failed and print warning messages + /// + /// true in case of no error, false otherwise + internal static bool WarnIfFailed(this Interop.ErrorCode err, string msg, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) + { + if (err.IsFailed()) + { + Log.Debug(LogTag, string.Format("{0}, err: {1}", msg, err.ToString()), file, func, line); + return false; + } + return true; + } + + /// + /// Utility method to check for error, returns false if failed and throw exception + /// + /// true in case of no error + internal static bool ThrowIfFailed(this Interop.ErrorCode err, string msg, [CallerFilePath] string file = "", [CallerMemberName] string func = "", [CallerLineNumber] int line = 0) + { + if (err.IsFailed()) + { + Log.Error(LogTag, string.Format("{0}, err: {1}", msg, err.ToString()), file, func, line); + throw err.GetException(msg); + } + return true; + } + + internal static Exception GetException(this Interop.ErrorCode err, string message) + { + string errMessage = string.Format("{0}, err: {1}", message, err.ToString()); + switch (err) + { + //case ErrorCode.None: + case Interop.ErrorCode.PermissionDenied: return new UnauthorizedAccessException(errMessage); + case Interop.ErrorCode.InvalidParameter: return new ArgumentException(errMessage); + case Interop.ErrorCode.OutOfMemory: + case Interop.ErrorCode.NotSupported: + case Interop.ErrorCode.ConnectionTimeOut: + case Interop.ErrorCode.NetworkUnreachable: + case Interop.ErrorCode.InvalidOperation: + case Interop.ErrorCode.KeyNotAvailable: + case Interop.ErrorCode.ResourceBusy: + case Interop.ErrorCode.Canceled: + case Interop.ErrorCode.Unknown: + case Interop.ErrorCode.ServiceNotAvailable: + case Interop.ErrorCode.NotFound: + default: return new InvalidOperationException(errMessage); + } + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Interop/Interop.Libraries.cs b/src/Tizen.Maps/Interop/Interop.Libraries.cs new file mode 100755 index 0000000..03be6b6 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Libraries.cs @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +internal static partial class Interop +{ + internal static class Libraries + { + internal const string MapService = "capi-maps-service.so.0"; + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Interop/Interop.Place.Attribute.cs b/src/Tizen.Maps/Interop/Interop.Place.Attribute.cs new file mode 100755 index 0000000..a301626 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Attribute.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceAttribute + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_attribute_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_attribute_h */ attribute); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_attribute_clone")] + internal static extern ErrorCode Clone(PlaceAttributeHandle /* maps_place_attribute_h */ origin, out IntPtr /* maps_place_attribute_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_attribute_get_id")] + internal static extern ErrorCode GetId(PlaceAttributeHandle /* maps_place_attribute_h */ attribute, out string id); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_attribute_get_label")] + internal static extern ErrorCode GetLabel(PlaceAttributeHandle /* maps_place_attribute_h */ attribute, out string label); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_attribute_get_text")] + internal static extern ErrorCode GetText(PlaceAttributeHandle /* maps_place_attribute_h */ attribute, out string text); + } + + internal class PlaceAttributeHandle : SafeMapsHandle + { + public PlaceAttributeHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceAttribute.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Category.cs b/src/Tizen.Maps/Interop/Interop.Place.Category.cs new file mode 100755 index 0000000..a8b547c --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Category.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceCategory + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_create")] + internal static extern ErrorCode Create(out IntPtr /* maps_place_category_h */ category); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_clone")] + internal static extern ErrorCode Clone(PlaceCategoryHandle /* maps_place_category_h */ origin, out IntPtr /* maps_place_category_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_category_h */ category); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_get_id")] + internal static extern ErrorCode GetId(PlaceCategoryHandle /* maps_place_category_h */ category, out string id); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_get_name")] + internal static extern ErrorCode GetName(PlaceCategoryHandle /* maps_place_category_h */ category, out string name); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_get_url")] + internal static extern ErrorCode GetUrl(PlaceCategoryHandle /* maps_place_category_h */ category, out string url); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_set_id")] + internal static extern ErrorCode SetId(PlaceCategoryHandle /* maps_place_category_h */ category, string id); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_set_name")] + internal static extern ErrorCode SetName(PlaceCategoryHandle /* maps_place_category_h */ category, string name); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_category_set_url")] + internal static extern ErrorCode SetUrl(PlaceCategoryHandle /* maps_place_category_h */ category, string url); + } + + internal class PlaceCategoryHandle : SafeMapsHandle + { + public PlaceCategoryHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceCategory.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Contact.cs b/src/Tizen.Maps/Interop/Interop.Place.Contact.cs new file mode 100755 index 0000000..3d4b430 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Contact.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceContact + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_contact_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_contact_h */ contact); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_contact_clone")] + internal static extern ErrorCode Clone(PlaceContactHandle /* maps_place_contact_h */ origin, out IntPtr /* maps_place_contact_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_contact_get_label")] + internal static extern ErrorCode GetLabel(PlaceContactHandle /* maps_place_contact_h */ contact, out string label); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_contact_get_type")] + internal static extern ErrorCode GetType(PlaceContactHandle /* maps_place_contact_h */ contact, out string type); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_contact_get_value")] + internal static extern ErrorCode GetValue(PlaceContactHandle /* maps_place_contact_h */ contact, out string value); + } + + internal class PlaceContactHandle : SafeMapsHandle + { + public PlaceContactHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceContact.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Editorial.cs b/src/Tizen.Maps/Interop/Interop.Place.Editorial.cs new file mode 100755 index 0000000..9b974b2 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Editorial.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceEditorial + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_editorial_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_editorial_h */ editorial); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_editorial_clone")] + internal static extern ErrorCode Clone(PlaceEditorialHandle /* maps_place_editorial_h */ origin, out IntPtr /* maps_place_editorial_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_editorial_get_description")] + internal static extern ErrorCode GetDescription(PlaceEditorialHandle /* maps_place_editorial_h */ editorial, out string description); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_editorial_get_language")] + internal static extern ErrorCode GetLanguage(PlaceEditorialHandle /* maps_place_editorial_h */ editorial, out string language); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_editorial_get_media")] + internal static extern ErrorCode GetMedia(PlaceEditorialHandle /* maps_place_editorial_h */ editorial, out IntPtr /* maps_place_media_h */ media); + } + + internal class PlaceEditorialHandle : SafeMapsHandle + { + public PlaceEditorialHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceEditorial.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Filter.cs b/src/Tizen.Maps/Interop/Interop.Place.Filter.cs new file mode 100755 index 0000000..4ca7185 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Filter.cs @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceFilter + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool PlaceFilterPropertiesCallback(int index, int total, string key, IntPtr /* void */ value, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_create")] + internal static extern ErrorCode Create(out IntPtr /* maps_place_filter_h */ filter); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_filter_h */ filter); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_clone")] + internal static extern ErrorCode Clone(PlaceFilterHandle /* maps_place_filter_h */ origin, out IntPtr /* maps_place_filter_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get")] + internal static extern ErrorCode Get(PlaceFilterHandle /* maps_place_filter_h */ filter, string key, out string value); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_keyword")] + internal static extern ErrorCode GetKeyword(PlaceFilterHandle /* maps_place_filter_h */ filter, out string keyword); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_place_name")] + internal static extern ErrorCode GetPlaceName(PlaceFilterHandle /* maps_place_filter_h */ filter, out string placeName); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_category")] + internal static extern ErrorCode GetCategory(PlaceFilterHandle /* maps_place_filter_h */ filter, out IntPtr /* maps_place_category_h */ category); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_foreach_property")] + internal static extern ErrorCode ForeachProperty(PlaceFilterHandle /* maps_place_filter_h */ filter, PlaceFilterPropertiesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_get_place_address")] + internal static extern ErrorCode GetPlaceAddress(PlaceFilterHandle /* maps_place_filter_h */ filter, out string placeAddress); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set")] + internal static extern ErrorCode Set(PlaceFilterHandle /* maps_place_filter_h */ filter, string key, string value); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_keyword")] + internal static extern ErrorCode SetKeyword(PlaceFilterHandle /* maps_place_filter_h */ filter, string keyword); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_place_name")] + internal static extern ErrorCode SetPlaceName(PlaceFilterHandle /* maps_place_filter_h */ filter, string placeName); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_category")] + internal static extern ErrorCode SetCategory(PlaceFilterHandle /* maps_place_filter_h */ filter, PlaceCategoryHandle /* maps_place_category_h */ category); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_filter_set_place_address")] + internal static extern ErrorCode SetPlaceAddress(PlaceFilterHandle /* maps_place_filter_h */ filter, string placeAddress); + } + + internal class PlaceFilterHandle : SafeMapsHandle + { + public PlaceFilterHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceFilter.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Image.cs b/src/Tizen.Maps/Interop/Interop.Place.Image.cs new file mode 100755 index 0000000..7ad7b64 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Image.cs @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceImage + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_image_h */ image); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_clone")] + internal static extern ErrorCode Clone(PlaceImageHandle /* maps_place_image_h */ origin, out IntPtr /* maps_place_image_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_get_id")] + internal static extern ErrorCode GetId(PlaceImageHandle /* maps_place_image_h */ image, out string id); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_get_url")] + internal static extern ErrorCode GetUrl(PlaceImageHandle /* maps_place_image_h */ image, out string url); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_get_width")] + internal static extern ErrorCode GetWidth(PlaceImageHandle /* maps_place_image_h */ image, out int width); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_get_height")] + internal static extern ErrorCode GetHeight(PlaceImageHandle /* maps_place_image_h */ image, out int height); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_get_user_link")] + internal static extern ErrorCode GetUserLink(PlaceImageHandle /* maps_place_image_h */ image, out IntPtr /* maps_place_link_object_h */ user); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_image_get_media")] + internal static extern ErrorCode GetMedia(PlaceImageHandle /* maps_place_image_h */ image, out IntPtr /* maps_place_media_h */ media); + } + + internal class PlaceImageHandle : SafeMapsHandle + { + public PlaceImageHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceImage.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Link.Object.cs b/src/Tizen.Maps/Interop/Interop.Place.Link.Object.cs new file mode 100755 index 0000000..9bcff08 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Link.Object.cs @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceLinkObject + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_link_object_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_link_object_h */ link); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_link_object_clone")] + internal static extern ErrorCode Clone(PlaceLinkObjectHandle /* maps_place_link_object_h */ origin, out IntPtr /* maps_place_link_object_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_link_object_get_id")] + internal static extern ErrorCode GetId(PlaceLinkObjectHandle /* maps_place_link_object_h */ link, out string id); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_link_object_get_name")] + internal static extern ErrorCode GetName(PlaceLinkObjectHandle /* maps_place_link_object_h */ link, out string name); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_link_object_get_string")] + internal static extern ErrorCode GetString(PlaceLinkObjectHandle /* maps_place_link_object_h */ link, out string linkString); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_link_object_get_type")] + internal static extern ErrorCode GetType(PlaceLinkObjectHandle /* maps_place_link_object_h */ link, out string type); + } + + internal class PlaceLinkObjectHandle : SafeMapsHandle + { + public PlaceLinkObjectHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceLinkObject.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Media.cs b/src/Tizen.Maps/Interop/Interop.Place.Media.cs new file mode 100755 index 0000000..133d4a0 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Media.cs @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceMedia + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_media_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_media_h */ media); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_media_clone")] + internal static extern ErrorCode Clone(PlaceMediaHandle /* maps_place_media_h */ origin, out IntPtr /* maps_place_media_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_media_get_attribution")] + internal static extern ErrorCode GetAttribution(PlaceMediaHandle /* maps_place_media_h */ media, out string attribution); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_media_get_supplier")] + internal static extern ErrorCode GetSupplier(PlaceMediaHandle /* maps_place_media_h */ media, out IntPtr /* maps_place_link_object_h */ supplier); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_media_get_via")] + internal static extern ErrorCode GetVia(PlaceMediaHandle /* maps_place_media_h */ media, out IntPtr /* maps_place_link_object_h */ via); + } + + internal class PlaceMediaHandle : SafeMapsHandle + { + public PlaceMediaHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceMedia.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Rating.cs b/src/Tizen.Maps/Interop/Interop.Place.Rating.cs new file mode 100755 index 0000000..fe3965a --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Rating.cs @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceRating + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_rating_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_rating_h */ rating); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_rating_clone")] + internal static extern ErrorCode Clone(PlaceRatingHandle /* maps_place_rating_h */ origin, out IntPtr /* maps_place_rating_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_rating_get_count")] + internal static extern ErrorCode GetCount(PlaceRatingHandle /* maps_place_rating_h */ rating, out int count); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_rating_get_average")] + internal static extern ErrorCode GetAverage(PlaceRatingHandle /* maps_place_rating_h */ rating, out double average); + } + + internal class PlaceRatingHandle : SafeMapsHandle + { + public PlaceRatingHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceRating.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.Review.cs b/src/Tizen.Maps/Interop/Interop.Place.Review.cs new file mode 100755 index 0000000..c3f7fb8 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.Review.cs @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class PlaceReview + { + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_review_h */ review); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_clone")] + internal static extern ErrorCode Clone(PlaceReviewHandle /* maps_place_review_h */ origin, out IntPtr /* maps_place_review_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_date")] + internal static extern ErrorCode GetDate(PlaceReviewHandle /* maps_place_review_h */ review, out string date); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_title")] + internal static extern ErrorCode GetTitle(PlaceReviewHandle /* maps_place_review_h */ review, out string title); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_rating")] + internal static extern ErrorCode GetRating(PlaceReviewHandle /* maps_place_review_h */ review, out double rating); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_description")] + internal static extern ErrorCode GetDescription(PlaceReviewHandle /* maps_place_review_h */ review, out string description); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_language")] + internal static extern ErrorCode GetLanguage(PlaceReviewHandle /* maps_place_review_h */ review, out string language); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_media")] + internal static extern ErrorCode GetMedia(PlaceReviewHandle /* maps_place_review_h */ review, out IntPtr /* maps_place_media_h */ media); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_review_get_user_link")] + internal static extern ErrorCode GetUserLink(PlaceReviewHandle /* maps_place_review_h */ review, out IntPtr /* maps_place_link_object_h */ user); + } + + internal class PlaceReviewHandle : SafeMapsHandle + { + public PlaceReviewHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = PlaceReview.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Place.cs b/src/Tizen.Maps/Interop/Interop.Place.cs new file mode 100755 index 0000000..a03cca9 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Place.cs @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Place + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool PropertiesCallback(int index, int total, string key, string /* void */ value, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool CategoriesCallback(int index, int total, IntPtr /* maps_place_category_h */ category, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool AttributesCallback(int index, int total, IntPtr /* maps_place_attribute_h */ attribute, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool ContactsCallback(int index, int total, IntPtr /* maps_place_contact_h */ contact, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool EditorialsCallback(int index, int total, IntPtr /* maps_place_editorial_h */ editorial, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool ImagesCallback(int index, int total, IntPtr /* maps_place_image_h */ image, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool ReviewsCallback(int index, int total, IntPtr /* maps_place_review_h */ review, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool PlaceCallback(int index, IntPtr /* maps_place_h */ place, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_place_h */ place); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_clone")] + internal static extern ErrorCode Clone(PlaceHandle /* maps_place_h */ origin, out IntPtr /* maps_place_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_id")] + internal static extern ErrorCode GetId(PlaceHandle /* maps_place_h */ place, out string id); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_name")] + internal static extern ErrorCode GetName(PlaceHandle /* maps_place_h */ place, out string name); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_uri")] + internal static extern ErrorCode GetUri(PlaceHandle /* maps_place_h */ place, out string uri); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_location")] + internal static extern ErrorCode GetLocation(PlaceHandle /* maps_place_h */ place, out IntPtr /* maps_coordinates_h */ location); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_distance")] + internal static extern ErrorCode GetDistance(PlaceHandle /* maps_place_h */ place, out int distance); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_address")] + internal static extern ErrorCode GetAddress(PlaceHandle /* maps_place_h */ place, out IntPtr /* maps_address_h */ address); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_rating")] + internal static extern ErrorCode GetRating(PlaceHandle /* maps_place_h */ place, out IntPtr /* maps_place_rating_h */ rating); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_property")] + internal static extern ErrorCode ForeachProperty(PlaceHandle /* maps_place_h */ place, PropertiesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_category")] + internal static extern ErrorCode ForeachCategory(PlaceHandle /* maps_place_h */ place, CategoriesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_attribute")] + internal static extern ErrorCode ForeachAttribute(PlaceHandle /* maps_place_h */ place, AttributesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_contact")] + internal static extern ErrorCode ForeachContact(PlaceHandle /* maps_place_h */ place, ContactsCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_editorial")] + internal static extern ErrorCode ForeachEditorial(PlaceHandle /* maps_place_h */ place, EditorialsCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_image")] + internal static extern ErrorCode ForeachImage(PlaceHandle /* maps_place_h */ place, ImagesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_foreach_review")] + internal static extern ErrorCode ForeachReview(PlaceHandle /* maps_place_h */ place, ReviewsCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_supplier_link")] + internal static extern ErrorCode GetSupplierLink(PlaceHandle /* maps_place_h */ place, out IntPtr /* maps_place_link_object_h */ supplier); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_get_related_link")] + internal static extern ErrorCode GetRelatedLink(PlaceHandle /* maps_place_h */ place, out IntPtr /* maps_place_link_object_h */ related); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_list_foreach")] + internal static extern ErrorCode ListForeach(PlaceListHandle /* maps_place_list_h */ placeList, PlaceCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_place_list_destroy")] + internal static extern ErrorCode ListDestroy(IntPtr /* maps_place_list_h */ placeList); + } + + internal class PlaceHandle : SafeMapsHandle + { + public PlaceHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Place.Destroy; } + } + + internal class PlaceListHandle : SafeMapsHandle + { + public PlaceListHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Place.ListDestroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Preference.cs b/src/Tizen.Maps/Interop/Interop.Preference.cs new file mode 100755 index 0000000..edae298 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Preference.cs @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum DistanceUnit + { + Meter, // MAPS_DISTANCE_UNIT_M + Kilometer, // MAPS_DISTANCE_UNIT_KM + Foot, // MAPS_DISTANCE_UNIT_FT + Yard, // MAPS_DISTANCE_UNIT_YD + } + + internal enum RouteOptimization + { + Fastest, // MAPS_ROUTE_TYPE_FASTEST + Shortest, // MAPS_ROUTE_TYPE_SHORTEST + Economic, // MAPS_ROUTE_TYPE_ECONOMIC + Scenic, // MAPS_ROUTE_TYPE_SCENIC + FastestNow, // MAPS_ROUTE_TYPE_FASTESTNOW + DirectDrive, // MAPS_ROUTE_TYPE_DIRECTDRIVE + } + + internal enum RouteTransportMode + { + Car, // MAPS_ROUTE_TRANSPORT_MODE_CAR + Pedestrian, // MAPS_ROUTE_TRANSPORT_MODE_PEDESTRIAN + Bicycle, // MAPS_ROUTE_TRANSPORT_MODE_BICYCLE + PublicTransit, // MAPS_ROUTE_TRANSPORT_MODE_PUBLICTRANSIT + Truck, // MAPS_ROUTE_TRANSPORT_MODE_TRUCK + } + + internal enum RouteFeatureWeight + { + Normal, // MAPS_ROUTE_FEATURE_WEIGHT_NORMAL + Prefer, // MAPS_ROUTE_FEATURE_WEIGHT_PREFER + Avoid, // MAPS_ROUTE_FEATURE_WEIGHT_AVOID + SoftExclude, // MAPS_ROUTE_FEATURE_WEIGHT_SOFTEXCLUDE + StrictExclude, // MAPS_ROUTE_FEATURE_WEIGHT_STRICTEXCLUDE + } + + internal enum RouteRequestFeature + { + None, // MAPS_ROUTE_FEATURE_NO + Toll, // MAPS_ROUTE_FEATURE_TOLL + MotorWay, // MAPS_ROUTE_FEATURE_MOTORWAY + BoatFerry, // MAPS_ROUTE_FEATURE_BOATFERRY + RailFerry, // MAPS_ROUTE_FEATURE_RAILFERRY + PublicTransit, // MAPS_ROUTE_FEATURE_PUBLICTTRANSIT + Tunnel, // MAPS_ROUTE_FEATURE_TUNNEL + DirtRoad, // MAPS_ROUTE_FEATURE_DIRTROAD + Parks, // MAPS_ROUTE_FEATURE_PARKS + Hovlane, // MAPS_ROUTE_FEATURE_HOVLANE + Stairs, // MAPS_ROUTE_FEATURE_STAIRS + } + + internal static partial class Preference + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool PreferencePropertiesCallback(int index, int total, string key, string value, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_create")] + internal static extern ErrorCode Create(out IntPtr /* maps_preference_h */ preference); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_preference_h */ preference); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_clone")] + internal static extern ErrorCode Clone(PreferenceHandle /* maps_preference_h */ origin, out IntPtr /* maps_preference_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_distance_unit")] + internal static extern ErrorCode GetDistanceUnit(PreferenceHandle /* maps_preference_h */ preference, out DistanceUnit? /* maps_distance_unit_e */ unit); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_language")] + internal static extern ErrorCode GetLanguage(PreferenceHandle /* maps_preference_h */ preference, out string language); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_max_results")] + internal static extern ErrorCode GetMaxResults(PreferenceHandle /* maps_preference_h */ preference, out int maxResults); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_country_code")] + internal static extern ErrorCode GetCountryCode(PreferenceHandle /* maps_preference_h */ preference, out string countryCode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_route_optimization")] + internal static extern ErrorCode GetRouteOptimization(PreferenceHandle /* maps_preference_h */ preference, out RouteOptimization? /* maps_route_optimization_e */ optimization); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_route_transport_mode")] + internal static extern ErrorCode GetRouteTransportMode(PreferenceHandle /* maps_preference_h */ preference, out RouteTransportMode? /* maps_route_transport_mode_e */ transportMode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_route_feature_weight")] + internal static extern ErrorCode GetRouteFeatureWeight(PreferenceHandle /* maps_preference_h */ preference, out RouteFeatureWeight? /* maps_route_feature_weight_e */ featureWeight); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_route_feature")] + internal static extern ErrorCode GetRouteFeature(PreferenceHandle /* maps_preference_h */ preference, out RouteRequestFeature? /* maps_route_feature_e */ feature); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get_route_alternatives_enabled")] + internal static extern ErrorCode GetRouteAlternativesEnabled(PreferenceHandle /* maps_preference_h */ preference, out bool? enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_get")] + internal static extern ErrorCode Get(PreferenceHandle /* maps_preference_h */ preference, string key, out string value); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_foreach_property")] + internal static extern ErrorCode ForeachProperty(PreferenceHandle /* maps_preference_h */ preference, PreferencePropertiesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_distance_unit")] + internal static extern ErrorCode SetDistanceUnit(PreferenceHandle /* maps_preference_h */ preference, DistanceUnit /* maps_distance_unit_e */ unit); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_language")] + internal static extern ErrorCode SetLanguage(PreferenceHandle /* maps_preference_h */ preference, string language); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_max_results")] + internal static extern ErrorCode SetMaxResults(PreferenceHandle /* maps_preference_h */ preference, int maxResults); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_country_code")] + internal static extern ErrorCode SetCountryCode(PreferenceHandle /* maps_preference_h */ preference, string countryCode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_route_optimization")] + internal static extern ErrorCode SetRouteOptimization(PreferenceHandle /* maps_preference_h */ preference, RouteOptimization /* maps_route_optimization_e */ optimization); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_route_transport_mode")] + internal static extern ErrorCode SetRouteTransportMode(PreferenceHandle /* maps_preference_h */ preference, RouteTransportMode /* maps_route_transport_mode_e */ transportMode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_route_feature_weight")] + internal static extern ErrorCode SetRouteFeatureWeight(PreferenceHandle /* maps_preference_h */ preference, RouteFeatureWeight /* maps_route_feature_weight_e */ featureWeight); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_route_feature")] + internal static extern ErrorCode SetRouteFeature(PreferenceHandle /* maps_preference_h */ preference, RouteRequestFeature /* maps_route_feature_e */ feature); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_route_alternatives_enabled")] + internal static extern ErrorCode SetRouteAlternativesEnabled(PreferenceHandle /* maps_preference_h */ preference, bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_preference_set_property")] + internal static extern ErrorCode SetProperty(PreferenceHandle /* maps_preference_h */ preference, string key, string value); + } + + internal class PreferenceHandle : SafeMapsHandle + { + public PreferenceHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Preference.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Route.Maneuver.cs b/src/Tizen.Maps/Interop/Interop.Route.Maneuver.cs new file mode 100755 index 0000000..5458b8c --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Route.Maneuver.cs @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum RouteDirection + { + None, // MAPS_ROUTE_DIRECTION_NONE + North, // MAPS_ROUTE_DIRECTION_NORTH + NorthWest, // MAPS_ROUTE_DIRECTION_NORTHWEST + NorthEast, // MAPS_ROUTE_DIRECTION_NORTHEAST + South, // MAPS_ROUTE_DIRECTION_SOUTH + SouthEast, // MAPS_ROUTE_DIRECTION_SOUTHEAST + SouthWest, // MAPS_ROUTE_DIRECTION_SOUTHWEST + West, // MAPS_ROUTE_DIRECTION_WEST + East, // MAPS_ROUTE_DIRECTION_EAST + } + + internal enum RouteTurnType + { + None, // MAPS_ROUTE_TURN_TYPE_NONE + Straight, // MAPS_ROUTE_TURN_TYPE_STRAIGHT + BearRight, // MAPS_ROUTE_TURN_TYPE_BEAR_RIGHT + LightRight, // MAPS_ROUTE_TURN_TYPE_LIGHT_RIGHT + Right, // MAPS_ROUTE_TURN_TYPE_RIGHT + HardRight, // MAPS_ROUTE_TURN_TYPE_HARD_RIGHT + UturnRight, // MAPS_ROUTE_TURN_TYPE_UTURN_RIGHT + UturnLeft, // MAPS_ROUTE_TURN_TYPE_UTURN_LEFT + HardLeft, // MAPS_ROUTE_TURN_TYPE_HARD_LEFT + Left, // MAPS_ROUTE_TURN_TYPE_LEFT + LightLeft, // MAPS_ROUTE_TURN_TYPE_LIGHT_LEFT + BearLeft, // MAPS_ROUTE_TURN_TYPE_BEAR_LEFT + RightFork, // MAPS_ROUTE_TURN_TYPE_RIGHT_FORK + LeftFork, // MAPS_ROUTE_TURN_TYPE_LEFT_FORK + StraightFork, // MAPS_ROUTE_TURN_TYPE_STRAIGHT_FORK + } + + internal static partial class RouteManeuver + { + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_route_maneuver_h */ maneuver); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_clone")] + internal static extern ErrorCode Clone(RouteManeuverHandle /* maps_route_maneuver_h */ origin, out IntPtr /* maps_route_maneuver_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_direction_id")] + internal static extern ErrorCode GetDirectionId(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out RouteDirection /* maps_route_direction_e */ directionId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_turn_type")] + internal static extern ErrorCode GetTurnType(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out RouteTurnType /* maps_route_turn_type_e */ turnType); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_position")] + internal static extern ErrorCode GetPosition(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out IntPtr /* maps_coordinates_h */ position); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_road_name")] + internal static extern ErrorCode GetRoadName(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out string roadName); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_instruction_text")] + internal static extern ErrorCode GetInstructionText(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out string instructionText); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_locale")] + internal static extern ErrorCode GetLocale(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out string locale); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_time_to_next_instruction")] + internal static extern ErrorCode GetTimeToNextInstruction(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out int timeToNextInstruction); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_maneuver_get_distance_to_next_instruction")] + internal static extern ErrorCode GetDistanceToNextInstruction(RouteManeuverHandle /* maps_route_maneuver_h */ maneuver, out double distanceToNextInstruction); + } + + internal class RouteManeuverHandle : SafeMapsHandle + { + public RouteManeuverHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = RouteManeuver.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Route.Segment.cs b/src/Tizen.Maps/Interop/Interop.Route.Segment.cs new file mode 100755 index 0000000..c8c9811 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Route.Segment.cs @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class RouteSegment + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool SegmentPathCallback(int index, int total, IntPtr /* maps_coordinates_h */ coordinates, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool SegmentManeuverCallback(int index, int total, IntPtr /* maps_route_maneuver_h */ maneuver, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_route_segment_h */ segment); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_clone")] + internal static extern ErrorCode Clone(RouteSegmentHandle /* maps_route_segment_h */ origin, out IntPtr /* maps_route_segment_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_get_origin")] + internal static extern ErrorCode GetOrigin(RouteSegmentHandle /* maps_route_segment_h */ segment, out IntPtr /* maps_coordinates_h */ origin); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_get_destination")] + internal static extern ErrorCode GetDestination(RouteSegmentHandle /* maps_route_segment_h */ segment, out IntPtr /* maps_coordinates_h */ destination); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_get_bounding_box")] + internal static extern ErrorCode GetBoundingBox(RouteSegmentHandle /* maps_route_segment_h */ segment, out IntPtr /* maps_area_h */ boundingBox); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_get_distance")] + internal static extern ErrorCode GetDistance(RouteSegmentHandle /* maps_route_segment_h */ segment, out double distance); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_get_duration")] + internal static extern ErrorCode GetDuration(RouteSegmentHandle /* maps_route_segment_h */ segment, out long duration); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_foreach_path")] + internal static extern ErrorCode ForeachPath(RouteSegmentHandle /* maps_route_segment_h */ segment, SegmentPathCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_segment_foreach_maneuver")] + internal static extern ErrorCode ForeachManeuver(RouteSegmentHandle /* maps_route_segment_h */ segment, SegmentManeuverCallback callback, IntPtr /* void */ userData); + } + + internal class RouteSegmentHandle : SafeMapsHandle + { + public RouteSegmentHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = RouteSegment.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Route.cs b/src/Tizen.Maps/Interop/Interop.Route.cs new file mode 100755 index 0000000..23e0241 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Route.cs @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Route + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool RoutePropertiesCallback(int index, int total, string key, string /* void */ value, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool RoutePathCallback(int index, int total, IntPtr /* maps_coordinates_h */ coordinates, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool RouteSegmentCallback(int index, int total, IntPtr /* maps_route_segment_h */ segment, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_route_h */ route); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_clone")] + internal static extern ErrorCode Clone(RouteHandle /* maps_route_h */ origin, out IntPtr /* maps_route_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_route_id")] + internal static extern ErrorCode GetRouteId(RouteHandle /* maps_route_h */ route, out string routeId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_origin")] + internal static extern ErrorCode GetOrigin(RouteHandle /* maps_route_h */ route, out IntPtr /* maps_coordinates_h */ origin); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_destination")] + internal static extern ErrorCode GetDestination(RouteHandle /* maps_route_h */ route, out IntPtr /* maps_coordinates_h */ destination); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_bounding_box")] + internal static extern ErrorCode GetBoundingBox(RouteHandle /* maps_route_h */ route, out IntPtr /* maps_area_h */ boundingBox); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_transport_mode")] + internal static extern ErrorCode GetTransportMode(RouteHandle /* maps_route_h */ route, out RouteTransportMode /* maps_route_transport_mode_e */ transportMode); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_total_distance")] + internal static extern ErrorCode GetTotalDistance(RouteHandle /* maps_route_h */ route, out double totalDistance); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_total_duration")] + internal static extern ErrorCode GetTotalDuration(RouteHandle /* maps_route_h */ route, out long totalDuration); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_get_distance_unit")] + internal static extern ErrorCode GetDistanceUnit(RouteHandle /* maps_route_h */ route, out DistanceUnit /* maps_distance_unit_e */ distanceUnit); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_foreach_property")] + internal static extern ErrorCode ForeachProperty(RouteHandle /* maps_route_h */ route, RoutePropertiesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_foreach_path")] + internal static extern ErrorCode ForeachPath(RouteHandle /* maps_route_h */ route, RoutePathCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_route_foreach_segment")] + internal static extern ErrorCode ForeachSegment(RouteHandle /* maps_route_h */ route, RouteSegmentCallback callback, IntPtr /* void */ userData); + } + + internal class RouteHandle : SafeMapsHandle + { + public RouteHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = Route.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.SafeMapsHandle.cs b/src/Tizen.Maps/Interop/Interop.SafeMapsHandle.cs new file mode 100755 index 0000000..32ce999 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.SafeMapsHandle.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + + +internal static partial class Interop +{ + internal class SafeMapsHandle : SafeHandle + { + public delegate ErrorCode HandleDestroy(IntPtr handle); + + private bool _hasOwnership = true; + protected HandleDestroy Destroy = null; + + internal SafeMapsHandle(IntPtr handle, bool ownsHandle = true) : base(handle, true) + { + _hasOwnership = ownsHandle; + } + public override bool IsInvalid { get { return handle == IntPtr.Zero; } } + public bool IsValid { get { return IsInvalid == false; } } + public void ReleaseOwnership() { _hasOwnership = false; } + + protected override bool ReleaseHandle() + { + if (_hasOwnership) + { + var err = Destroy?.Invoke(handle); + err?.WarnIfFailed(string.Format("Failed to delete native {0} handle", GetType())); + } + SetHandle(IntPtr.Zero); + return true; + } + + public static implicit operator IntPtr(SafeMapsHandle otherHandle) + { + return otherHandle.handle; + } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.Service.cs b/src/Tizen.Maps/Interop/Interop.Service.cs new file mode 100755 index 0000000..7ccf9cd --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.Service.cs @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum ServiceType + { + Geocode, // MAPS_SERVICE_GEOCODE + GeocodeInsideArea, // MAPS_SERVICE_GEOCODE_INSIDE_AREA + GeocodeByStructuredAddress, // MAPS_SERVICE_GEOCODE_BY_STRUCTURED_ADDRESS + ReverseGeocode, // MAPS_SERVICE_REVERSE_GEOCODE + SearchPlace, // MAPS_SERVICE_SEARCH_PLACE + SearchPlaceByArea, // MAPS_SERVICE_SEARCH_PLACE_BY_AREA + SearchPlaceByAddress, // MAPS_SERVICE_SEARCH_PLACE_BY_ADDRESS + SearchRoute, // MAPS_SERVICE_SEARCH_ROUTE + SearchRouteWaypoints, // MAPS_SERVICE_SEARCH_ROUTE_WAYPOINTS + CancelRequest, // MAPS_SERVICE_CANCEL_REQUEST + MultiReverseGeocode, // MAPS_SERVICE_MULTI_REVERSE_GEOCODE + SearchPlaceList, // MAPS_SERVICE_SEARCH_PLACE_LIST + SearchGetPlaceDetails, // MAPS_SERVICE_SEARCH_GET_PLACE_DETAILS + View, // MAPS_SERVICE_VIEW + ViewSnapshot, // MAPS_SERVICE_VIEW_SNAPSHOT + } + + internal enum ServiceData + { + PlaceAddress, // MAPS_PLACE_ADDRESS + PlaceRating, // MAPS_PLACE_RATING + PlaceCategories, // MAPS_PLACE_CATEGORIES + PlaceAttributes, // MAPS_PLACE_ATTRIBUTES + PlaceContacts, // MAPS_PLACE_CONTACTS + PlaceEditorials, // MAPS_PLACE_EDITORIALS + PlaceReviews, // MAPS_PLACE_REVIEWS + PlaceImage, // MAPS_PLACE_IMAGE + PlaceSupplier, // MAPS_PLACE_SUPPLIER + PlaceRelated, // MAPS_PLACE_RELATED + RoutePath, // MAPS_ROUTE_PATH + RouteSegmentsPath, // MAPS_ROUTE_SEGMENTS_PATH + RouteSegmentsManeuvers, // MAPS_ROUTE_SEGMENTS_MANEUVERS + ViewTraffic, // MAPS_VIEW_TRAFFIC + ViewPublicTransit, // MAPS_VIEW_PUBLIC_TRANSIT + ViewBuilding, // MAPS_VIEW_BUILDING + ViewScalebar, // MAPS_VIEW_SCALEBAR + } + + internal static partial class Service + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool ProviderInfoCallback(string mapsProvider, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void RequestUserConsentCallback(bool consented, string provider, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool GeocodeCallback(ErrorCode /* maps_error_e */ result, int requestId, int index, int total, IntPtr /* maps_coordinates_h */ coordinates, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void ReverseGeocodeCallback(ErrorCode /* maps_error_e */ result, int requestId, int index, int total, IntPtr /* maps_address_h */ address, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool MultiReverseGeocodeCallback(ErrorCode /* maps_error_e */ result, int requestId, int total, IntPtr /* maps_address_list_h */ addressList, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool SearchPlaceCallback(ErrorCode /* maps_error_e */ error, int requestId, int index, int total, IntPtr /* maps_place_h */ place, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void SearchPlaceListCallback(ErrorCode /* maps_error_e */ error, int requestId, int total, IntPtr /* maps_place_list_h */ placeList, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void GetPlaceDetailsCallback(ErrorCode /* maps_error_e */ error, int requestId, IntPtr /* maps_place_h */ place, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool SearchRouteCallback(ErrorCode /* maps_error_e */ error, int requestId, int index, int total, IntPtr /* maps_route_h */ route, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_foreach_provider")] + internal static extern ErrorCode ForeachProvider(ProviderInfoCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_request_user_consent")] + internal static extern ErrorCode RequestUserConsent(string provider, RequestUserConsentCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_create")] + internal static extern ErrorCode Create(string provider, out IntPtr /* maps_service_h */ maps); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_service_h */ maps); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_set_provider_key")] + internal static extern ErrorCode SetProviderKey(ServiceHandle /* maps_service_h */ maps, string providerKey); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_get_provider_key")] + internal static extern ErrorCode GetProviderKey(ServiceHandle /* maps_service_h */ maps, out string providerKey); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_set_preference")] + internal static extern ErrorCode SetPreference(ServiceHandle /* maps_service_h */ maps, PreferenceHandle /* maps_preference_h */ preference); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_get_preference")] + internal static extern ErrorCode GetPreference(ServiceHandle /* maps_service_h */ maps, out IntPtr /* maps_preference_h */ preference); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_provider_is_service_supported")] + internal static extern ErrorCode ProviderIsServiceSupported(ServiceHandle /* maps_service_h */ maps, ServiceType /* maps_service_e */ service, out bool supported); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_provider_is_data_supported")] + internal static extern ErrorCode ProviderIsDataSupported(ServiceHandle /* maps_service_h */ maps, ServiceData /* maps_service_data_e */ data, out bool supported); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_cancel_request")] + internal static extern ErrorCode CancelRequest(ServiceHandle /* maps_service_h */ maps, int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_geocode")] + internal static extern ErrorCode Geocode(ServiceHandle /* maps_service_h */ maps, string address, PreferenceHandle /* maps_preference_h */ preference, GeocodeCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_geocode_inside_area")] + internal static extern ErrorCode GeocodeInsideArea(ServiceHandle /* maps_service_h */ maps, string address, AreaHandle /* maps_area_h */ bounds, PreferenceHandle /* maps_preference_h */ preference, GeocodeCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_geocode_by_structured_address")] + internal static extern ErrorCode GeocodeByStructuredAddress(ServiceHandle /* maps_service_h */ maps, AddressHandle /* maps_address_h */ address, PreferenceHandle /* maps_preference_h */ preference, GeocodeCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_reverse_geocode")] + internal static extern ErrorCode ReverseGeocode(ServiceHandle /* maps_service_h */ maps, double latitude, double longitude, PreferenceHandle /* maps_preference_h */ preference, ReverseGeocodeCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_multi_reverse_geocode")] + internal static extern ErrorCode MultiReverseGeocode(ServiceHandle /* maps_service_h */ maps, CoordinatesListHandle /* maps_coordinates_list_h */ coordinatesList, PreferenceHandle /* maps_preference_h */ preference, MultiReverseGeocodeCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place")] + internal static extern ErrorCode SearchPlace(ServiceHandle /* maps_service_h */ maps, CoordinatesHandle /* maps_coordinates_h */ position, int distance, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place_by_area")] + internal static extern ErrorCode SearchPlaceByArea(ServiceHandle /* maps_service_h */ maps, AreaHandle /* maps_area_h */ boundary, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place_by_address")] + internal static extern ErrorCode SearchPlaceByAddress(ServiceHandle /* maps_service_h */ maps, string address, AreaHandle /* maps_area_h */ boundary, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_place_list")] + internal static extern ErrorCode SearchPlaceList(ServiceHandle /* maps_service_h */ maps, AreaHandle /* maps_area_h */ boundary, PlaceFilterHandle /* maps_place_filter_h */ filter, PreferenceHandle /* maps_preference_h */ preference, SearchPlaceListCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_get_place_details")] + internal static extern ErrorCode GetPlaceDetails(ServiceHandle /* maps_service_h */ maps, string uri, GetPlaceDetailsCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_route")] + internal static extern ErrorCode SearchRoute(ServiceHandle /* maps_service_h */ maps, CoordinatesHandle /* maps_coordinates_h */ origin, CoordinatesHandle /* maps_coordinates_h */ destination, PreferenceHandle /* maps_preference_h */ preference, SearchRouteCallback callback, IntPtr /* void */ userData, out int requestId); + + [DllImport(Libraries.MapService, EntryPoint = "maps_service_search_route_waypoints")] + internal static extern ErrorCode SearchRouteWaypoints(ServiceHandle /* maps_service_h */ maps, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] [In] IntPtr[] /* maps_coordinates_h */ waypointList, int waypointNum, PreferenceHandle /* maps_preference_h */ preference, SearchRouteCallback callback, IntPtr /* void */ userData, out int requestId); + } + + internal class ServiceHandle : SafeMapsHandle + { + internal ErrorCode DestroyHandle(IntPtr handle) { return Service.Destroy(handle); } + + public ServiceHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = DestroyHandle; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.View.Event.Data.cs b/src/Tizen.Maps/Interop/Interop.View.Event.Data.cs new file mode 100755 index 0000000..2480582 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.View.Event.Data.cs @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum ViewAction + { + None, // MAPS_VIEW_ACTION_NONE + Scroll, // MAPS_VIEW_ACTION_SCROLL + Zoom, // MAPS_VIEW_ACTION_ZOOM + ZoomIn, // MAPS_VIEW_ACTION_ZOOM_IN + ZoomOut, // MAPS_VIEW_ACTION_ZOOM_OUT + ZoomAndScroll, // MAPS_VIEW_ACTION_ZOOM_AND_SCROLL + Rotate, // MAPS_VIEW_ACTION_ROTATE + } + + internal enum ViewGesture + { + None, // MAPS_VIEW_GESTURE_NONE + Scroll, // MAPS_VIEW_GESTURE_SCROLL + Zoom, // MAPS_VIEW_GESTURE_ZOOM + Tap, // MAPS_VIEW_GESTURE_TAP + DoubleTap, // MAPS_VIEW_GESTURE_DOUBLE_TAP + TwoFingerTap, // MAPS_VIEW_GESTURE_2_FINGER_TAP + Rotate, // MAPS_VIEW_GESTURE_ROTATE + LongPress, // MAPS_VIEW_GESTURE_LONG_PRESS + } + + internal enum ViewEventType + { + Gesture, // MAPS_VIEW_EVENT_GESTURE + Action, // MAPS_VIEW_EVENT_ACTION + Object, // MAPS_VIEW_EVENT_OBJECT + Ready, // MAPS_VIEW_EVENT_READY + } + + internal static partial class ViewEventData + { + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_view_event_data_h */ viewEvent); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_clone")] + internal static extern ErrorCode Clone(IntPtr /* maps_view_event_data_h */ origin, out IntPtr /* maps_view_event_data_h */ cloned); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_type")] + internal static extern ErrorCode GetType(IntPtr /* maps_view_event_data_h */ viewEvent, out ViewEventType /* maps_view_event_type_e */ eventType); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_gesture_type")] + internal static extern ErrorCode GetGestureType(IntPtr /* maps_view_event_data_h */ viewEvent, out ViewGesture /* maps_view_gesture_e */ gestureType); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_action_type")] + internal static extern ErrorCode GetActionType(IntPtr /* maps_view_event_data_h */ viewEvent, out ViewAction /* maps_view_action_e */ actionType); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_center")] + internal static extern ErrorCode GetCenter(IntPtr /* maps_view_event_data_h */ viewEvent, out IntPtr /* maps_coordinates_h */ center); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_delta")] + internal static extern ErrorCode GetDelta(IntPtr /* maps_view_event_data_h */ viewEvent, out int deltaX, out int deltaY); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_position")] + internal static extern ErrorCode GetPosition(IntPtr /* maps_view_event_data_h */ viewEvent, out int x, out int y); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_coordinates")] + internal static extern ErrorCode GetCoordinates(IntPtr /* maps_view_event_data_h */ viewEvent, out IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_fingers")] + internal static extern ErrorCode GetFingers(IntPtr /* maps_view_event_data_h */ viewEvent, out int fingers); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_zoom_factor")] + internal static extern ErrorCode GetZoomFactor(IntPtr /* maps_view_event_data_h */ viewEvent, out double zoomFactor); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_rotation_angle")] + internal static extern ErrorCode GetRotationAngle(IntPtr /* maps_view_event_data_h */ viewEvent, out double rotationAngle); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_event_data_get_object")] + internal static extern ErrorCode GetObject(IntPtr /* maps_view_event_data_h */ viewEvent, out IntPtr /* maps_view_object_h */ viewEventDataObject); + } +} diff --git a/src/Tizen.Maps/Interop/Interop.View.Object.cs b/src/Tizen.Maps/Interop/Interop.View.Object.cs new file mode 100755 index 0000000..79fc394 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.View.Object.cs @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum ViewObjectType + { + Polyline, // MAPS_VIEW_OBJECT_POLYLINE + Polygon, // MAPS_VIEW_OBJECT_POLYGON + Marker, // MAPS_VIEW_OBJECT_MARKER + Overlay, // MAPS_VIEW_OBJECT_OVERLAY + } + + internal enum ViewMarkerType + { + Pin, // MAPS_VIEW_MARKER_PIN + Sticker, // MAPS_VIEW_MARKER_STICKER + } + + internal enum ViewOverlayType + { + Normal, // MAPS_VIEW_OVERLAY_NORMAL + Bubble, // MAPS_VIEW_OVERLAY_BUBBLE + Box, // MAPS_VIEW_OVERLAY_BOX + } + + internal static partial class ViewObject + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool CoordinatesCallback(int index, IntPtr /* maps_coordinates_h */ coordinates, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_create_marker")] + internal static extern ErrorCode CreateMarker(CoordinatesHandle /* maps_coordinates_h */ coordinates, string imageFilePath, ViewMarkerType /* maps_view_marker_type_e */ type, out IntPtr /* maps_view_object_h */ marker); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_create_polyline")] + internal static extern ErrorCode CreatePolyline(CoordinatesListHandle /* maps_coordinates_list_h */ coordinates, byte r, byte g, byte b, byte a, int width, out IntPtr /* maps_view_object_h */ polyline); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_create_polygon")] + internal static extern ErrorCode CreatePolygon(CoordinatesListHandle /* maps_coordinates_list_h */ coordinates, byte r, byte g, byte b, byte a, out IntPtr /* maps_view_object_h */ polygon); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_create_overlay")] + internal static extern ErrorCode CreateOverlay(CoordinatesHandle /* maps_coordinates_h */ coordinates, IntPtr viewObject, ViewOverlayType /* maps_view_overlay_type_e */ type, out IntPtr /* maps_view_object_h */ overlay); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_view_object_h */ viewObject); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_get_type")] + internal static extern ErrorCode GetType(ViewObjectHandle /* maps_view_object_h */ viewObject, out ViewObjectType /* maps_view_object_type_e */ type); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_set_visible")] + internal static extern ErrorCode SetVisible(ViewObjectHandle /* maps_view_object_h */ viewObject, bool visible); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_get_visible")] + internal static extern ErrorCode GetVisible(ViewObjectHandle /* maps_view_object_h */ viewObject, out bool visible); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polyline_set_polyline")] + internal static extern ErrorCode PolylineSetPolyline(ViewObjectHandle /* maps_view_object_h */ polyline, CoordinatesListHandle /* maps_coordinates_list_h */ points); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polyline_foreach_point")] + internal static extern ErrorCode PolylineForeachPoint(ViewObjectHandle /* maps_view_object_h */ polyline, CoordinatesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polyline_set_color")] + internal static extern ErrorCode PolylineSetColor(ViewObjectHandle /* maps_view_object_h */ polyline, byte r, byte g, byte b, byte a); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polyline_get_color")] + internal static extern ErrorCode PolylineGetColor(ViewObjectHandle /* maps_view_object_h */ polyline, out byte r, out byte g, out byte b, out byte a); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polyline_set_width")] + internal static extern ErrorCode PolylineSetWidth(ViewObjectHandle /* maps_view_object_h */ polyline, int width); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polyline_get_width")] + internal static extern ErrorCode PolylineGetWidth(ViewObjectHandle /* maps_view_object_h */ polyline, out int width); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polygon_set_polygon")] + internal static extern ErrorCode PolygonSetPolygon(ViewObjectHandle /* maps_view_object_h */ polygon, CoordinatesListHandle /* maps_coordinates_list_h */ points); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polygon_foreach_point")] + internal static extern ErrorCode PolygonForeachPoint(ViewObjectHandle /* maps_view_object_h */ polygon, CoordinatesCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polygon_set_fill_color")] + internal static extern ErrorCode PolygonSetFillColor(ViewObjectHandle /* maps_view_object_h */ polygon, byte r, byte g, byte b, byte a); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_polygon_get_fill_color")] + internal static extern ErrorCode PolygonGetFillColor(ViewObjectHandle /* maps_view_object_h */ polygon, out byte r, out byte g, out byte b, out byte a); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_set_coordinates")] + internal static extern ErrorCode MarkerSetCoordinates(ViewObjectHandle /* maps_view_object_h */ marker, CoordinatesHandle /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_resize")] + internal static extern ErrorCode MarkerResize(ViewObjectHandle /* maps_view_object_h */ marker, int width, int height); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_set_image_file")] + internal static extern ErrorCode MarkerSetImageFile(ViewObjectHandle /* maps_view_object_h */ marker, string filePath); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_image_file")] + internal static extern ErrorCode MarkerGetImageFile(ViewObjectHandle /* maps_view_object_h */ marker, out string filePath); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_coordinates")] + internal static extern ErrorCode MarkerGetCoordinates(ViewObjectHandle /* maps_view_object_h */ marker, out IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_size")] + internal static extern ErrorCode MarkerGetSize(ViewObjectHandle /* maps_view_object_h */ marker, out int width, out int height); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_type")] + internal static extern ErrorCode MarkerGetType(ViewObjectHandle /* maps_view_object_h */ marker, out ViewMarkerType /* maps_view_marker_type_e */ type); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_set_z_order")] + internal static extern ErrorCode MarkerSetZOrder(ViewObjectHandle /* maps_view_object_h */ marker, int zOrder); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_marker_get_z_order")] + internal static extern ErrorCode MarkerGetZOrder(ViewObjectHandle /* maps_view_object_h */ marker, out int zOrder); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_object")] + internal static extern ErrorCode OverlayGetObject(ViewObjectHandle /* maps_view_object_h */ overlay, out IntPtr viewObject); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_set_coordinates")] + internal static extern ErrorCode OverlaySetCoordinates(ViewObjectHandle /* maps_view_object_h */ overlay, CoordinatesHandle /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_coordinates")] + internal static extern ErrorCode OverlayGetCoordinates(ViewObjectHandle /* maps_view_object_h */ overlay, out IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_set_min_zoom_level")] + internal static extern ErrorCode OverlaySetMinZoomLevel(ViewObjectHandle /* maps_view_object_h */ overlay, int zoom); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_min_zoom_level")] + internal static extern ErrorCode OverlayGetMinZoomLevel(ViewObjectHandle /* maps_view_object_h */ overlay, out int zoom); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_set_max_zoom_level")] + internal static extern ErrorCode OverlaySetMaxZoomLevel(ViewObjectHandle /* maps_view_object_h */ overlay, int zoom); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_object_overlay_get_max_zoom_level")] + internal static extern ErrorCode OverlayGetMaxZoomLevel(ViewObjectHandle /* maps_view_object_h */ overlay, out int zoom); + } + + internal class ViewObjectHandle : SafeMapsHandle + { + public ViewObjectHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = ViewObject.Destroy; } + } +} diff --git a/src/Tizen.Maps/Interop/Interop.View.Snapshot.cs b/src/Tizen.Maps/Interop/Interop.View.Snapshot.cs new file mode 100755 index 0000000..d6403c6 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.View.Snapshot.cs @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum ViewSnapshotFormatType + { + ViewSnapshotBmp, // MAPS_VIEW_SNAPSHOT_BMP + ViewSnapshotJpeg, // MAPS_VIEW_SNAPSHOT_JPEG + } + + internal static partial class ViewSnapshot + { + [DllImport(Libraries.MapService, EntryPoint = "maps_view_capture_snapshot")] + internal static extern ErrorCode ViewCaptureSnapshot(ViewHandle /* maps_view_h */ view, ViewSnapshotFormatType /* maps_view_snapshot_format_type_e */ type, int quality, string path); + } +} diff --git a/src/Tizen.Maps/Interop/Interop.View.cs b/src/Tizen.Maps/Interop/Interop.View.cs new file mode 100755 index 0000000..c506647 --- /dev/null +++ b/src/Tizen.Maps/Interop/Interop.View.cs @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal enum ViewType + { + Normal, // MAPS_VIEW_TYPE_NORMAL + Satellite, // MAPS_VIEW_TYPE_SATELLITE + Terrain, // MAPS_VIEW_TYPE_TERRAIN + Hybrid, // MAPS_VIEW_TYPE_HYBRID + } + + internal static partial class View + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void ViewOnEventCallback(ViewEventType /* maps_view_event_type_e */ type, IntPtr /* maps_view_event_data_h */ eventData, IntPtr /* void */ userData); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate bool ViewObjectCallback(int index, int total, IntPtr /* maps_view_object_h */ viewObject, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_create")] + internal static extern ErrorCode Create(ServiceHandle /* maps_service_h */ maps, IntPtr obj, out IntPtr /* maps_view_h */ view); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_destroy")] + internal static extern ErrorCode Destroy(IntPtr /* maps_view_h */ view); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_center")] + internal static extern ErrorCode SetCenter(ViewHandle /* maps_view_h */ view, CoordinatesHandle /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_center")] + internal static extern ErrorCode GetCenter(ViewHandle /* maps_view_h */ view, out IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_zoom_level")] + internal static extern ErrorCode SetZoomLevel(ViewHandle /* maps_view_h */ view, int level); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_zoom_level")] + internal static extern ErrorCode GetZoomLevel(ViewHandle /* maps_view_h */ view, out int level); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_min_zoom_level")] + internal static extern ErrorCode SetMinZoomLevel(ViewHandle /* maps_view_h */ view, int level); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_min_zoom_level")] + internal static extern ErrorCode GetMinZoomLevel(ViewHandle /* maps_view_h */ view, out int minZoomLevel); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_max_zoom_level")] + internal static extern ErrorCode SetMaxZoomLevel(ViewHandle /* maps_view_h */ view, int level); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_max_zoom_level")] + internal static extern ErrorCode GetMaxZoomLevel(ViewHandle /* maps_view_h */ view, out int maxZoomLevel); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_orientation")] + internal static extern ErrorCode SetOrientation(ViewHandle /* maps_view_h */ view, double angle); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_orientation")] + internal static extern ErrorCode GetOrientation(ViewHandle /* maps_view_h */ view, out double rotationAngle); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_screen_to_geolocation")] + internal static extern ErrorCode ScreenToGeolocation(ViewHandle /* maps_view_h */ view, int x, int y, out IntPtr /* maps_coordinates_h */ coordinates); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_geolocation_to_screen")] + internal static extern ErrorCode GeolocationToScreen(ViewHandle /* maps_view_h */ view, CoordinatesHandle /* maps_coordinates_h */ coordinates, out int x, out int y); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_type")] + internal static extern ErrorCode SetType(ViewHandle /* maps_view_h */ view, ViewType /* maps_view_type_e */ type); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_type")] + internal static extern ErrorCode GetType(ViewHandle /* maps_view_h */ view, out ViewType /* maps_view_type_e */ type); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_buildings_enabled")] + internal static extern ErrorCode SetBuildingsEnabled(ViewHandle /* maps_view_h */ view, bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_buildings_enabled")] + internal static extern ErrorCode GetBuildingsEnabled(ViewHandle /* maps_view_h */ view, out bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_traffic_enabled")] + internal static extern ErrorCode SetTrafficEnabled(ViewHandle /* maps_view_h */ view, bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_traffic_enabled")] + internal static extern ErrorCode GetTrafficEnabled(ViewHandle /* maps_view_h */ view, out bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_public_transit_enabled")] + internal static extern ErrorCode SetPublicTransitEnabled(ViewHandle /* maps_view_h */ view, bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_public_transit_enabled")] + internal static extern ErrorCode GetPublicTransitEnabled(ViewHandle /* maps_view_h */ view, out bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_language")] + internal static extern ErrorCode SetLanguage(ViewHandle /* maps_view_h */ view, string language); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_language")] + internal static extern ErrorCode GetLanguage(ViewHandle /* maps_view_h */ view, out string language); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_scalebar_enabled")] + internal static extern ErrorCode SetScalebarEnabled(ViewHandle /* maps_view_h */ view, bool enable); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_scalebar_enabled")] + internal static extern ErrorCode GetScalebarEnabled(ViewHandle /* maps_view_h */ view, out bool enabled); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_viewport")] + internal static extern ErrorCode GetViewport(ViewHandle /* maps_view_h */ view, out IntPtr viewport); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_screen_location")] + internal static extern ErrorCode SetScreenLocation(ViewHandle /* maps_view_h */ view, int x, int y, int width, int height); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_screen_location")] + internal static extern ErrorCode GetScreenLocation(ViewHandle /* maps_view_h */ view, out int x, out int y, out int width, out int height); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_move")] + internal static extern ErrorCode Move(ViewHandle /* maps_view_h */ view, int x, int y); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_resize")] + internal static extern ErrorCode Resize(ViewHandle /* maps_view_h */ view, int width, int height); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_visibility")] + internal static extern ErrorCode SetVisibility(ViewHandle /* maps_view_h */ view, bool visible); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_visibility")] + internal static extern ErrorCode GetVisibility(ViewHandle /* maps_view_h */ view, out bool visible); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_event_cb")] + internal static extern ErrorCode SetEventCb(ViewHandle /* maps_view_h */ view, ViewEventType /* maps_view_event_type_e */ type, ViewOnEventCallback callback, IntPtr /* void */ userData); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_unset_event_cb")] + internal static extern ErrorCode UnsetEventCb(ViewHandle /* maps_view_h */ view, ViewEventType /* maps_view_event_type_e */ type); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_set_gesture_enabled")] + internal static extern ErrorCode SetGestureEnabled(ViewHandle /* maps_view_h */ view, ViewGesture /* maps_view_gesture_e */ gesture, bool enabled); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_get_gesture_enabled")] + internal static extern ErrorCode GetGestureEnabled(ViewHandle /* maps_view_h */ view, ViewGesture /* maps_view_gesture_e */ gesture, out bool enabled); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_add_object")] + internal static extern ErrorCode AddObject(ViewHandle /* maps_view_h */ view, ViewObjectHandle /* maps_view_object_h */ viewObject); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_remove_object")] + internal static extern ErrorCode RemoveObject(ViewHandle /* maps_view_h */ view, ViewObjectHandle /* maps_view_object_h */ viewObject); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_remove_all_objects")] + internal static extern ErrorCode RemoveAllObjects(ViewHandle /* maps_view_h */ view); + + [DllImport(Libraries.MapService, EntryPoint = "maps_view_foreach_object")] + internal static extern ErrorCode ForeachObject(ViewHandle /* maps_view_h */ view, ViewObjectCallback callback, IntPtr /* void */ userData); + } + + internal class ViewHandle : SafeMapsHandle + { + internal ErrorCode DestroyHandle(IntPtr handle) { return Service.Destroy(handle); } + + public ViewHandle(IntPtr handle, bool ownsHandle = true) : base(handle, ownsHandle) { Destroy = DestroyHandle; } + } +} diff --git a/src/Tizen.Maps/Properties/AssemblyInfo.cs b/src/Tizen.Maps/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..688b54f --- /dev/null +++ b/src/Tizen.Maps/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tizen.Maps")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tizen.Maps")] +[assembly: AssemblyCopyright("Copyright \u00A9 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5c091cb5-fd77-454f-a3b8-c67163250003")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Tizen.Maps/Tizen.Maps.Net45.csproj b/src/Tizen.Maps/Tizen.Maps.Net45.csproj new file mode 100755 index 0000000..2dc0f30 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps.Net45.csproj @@ -0,0 +1,137 @@ + + + + Debug + AnyCPU + {2C1FEDE6-C57A-4BD8-9660-E7AA90C740E5} + Library + Properties + + + Tizen.Maps + 512 + v4.5 + + + + true + full + false + bin\Debug\Net45\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\Net45\ + TRACE + prompt + 4 + + + true + + + Tizen.Maps.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Tizen.Maps/Tizen.Maps.Net45.project.json b/src/Tizen.Maps/Tizen.Maps.Net45.project.json new file mode 100644 index 0000000..50ad9cb --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps.Net45.project.json @@ -0,0 +1,17 @@ +{ + "buildOptions": { + "debugType": "portable", + "platform": "AnyCPU", + "preserveCompilationContext": true + }, + "dependencies": { + "Tizen": "1.0.2", + "ElmSharp": "1.1.0-*" + }, + "runtimes": { + "win": {} + }, + "frameworks": { + "net45": {} + } +} diff --git a/src/Tizen.Maps/Tizen.Maps.csproj b/src/Tizen.Maps/Tizen.Maps.csproj new file mode 100755 index 0000000..b0220c1 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps.csproj @@ -0,0 +1,154 @@ + + + + 14.0 + Debug + AnyCPU + 8.0.30703 + 2.0 + {5C091CB5-FD77-454F-A3B8-C67163250003} + Library + Properties + Tizen.Maps + Tizen.Maps + 512 + en-US + + + .NETStandard + v1.3 + .NETStandard,Version=v1.3 + .NETStandard,Version=v1.3 + false + true + $(NoWarn);1701 + false + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + + + Tizen.Maps.snk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory) + <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory) + true + + \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps.nuspec b/src/Tizen.Maps/Tizen.Maps.nuspec new file mode 100644 index 0000000..9051a5d --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps.nuspec @@ -0,0 +1,16 @@ + + + + Tizen.Maps + $version$ + Tizen Developers + Map Services API for Tizen.Net + + + + + + + + + diff --git a/src/Tizen.Maps/Tizen.Maps.project.json b/src/Tizen.Maps/Tizen.Maps.project.json new file mode 100755 index 0000000..a5893c4 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps.project.json @@ -0,0 +1,15 @@ +{ + "buildOptions": { + "debugType": "portable", + "platform": "AnyCPU", + "preserveCompilationContext": true + }, + "dependencies": { + "ElmSharp": "1.1.0-*", + "NETStandard.Library": "1.6.1", + "Tizen": "1.0.2" + }, + "frameworks": { + "netstandard1.3": {} + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps.snk b/src/Tizen.Maps/Tizen.Maps.snk new file mode 100755 index 0000000000000000000000000000000000000000..32ee425790f582e22609986ed2c3eaa9da6dbc6b GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096qN*f~s^_PMF%51lk-2qHm!63O~hMJ8V z0tw!OmXTKZ#sjjow1wcA?!Ns*h1}mJ>=i54 z4k!LZn@EH|g&%zWugY3gaaM(3ux>sNLb3pC10~vtkR3MI+6dDLr|-FPi0uZy`>~eBt^bW8!a!A6(2; zYzyQg5&{oPti{}m=vtdh68ih4bbDi2W_iI+Uzl;oa@k$_u^ddN{X3o*`x-eqL%CUS zK{BzUlBnI(uroP~_@wmJ)*d;Ixo5iJJ6nPJ)GTu18|94?X!1|bvJ`>QAbR|ov#ND~ zx6Kta*G(q~0#juI(}{3#E7S|&i)@7)sjkv~SRK>$=oOhEcMxmJ5T%@estKFLaE{d> zNSv5(N+TTie*1Cx;aOP5i^e6cQcD5wp@zkGcaIm!Y9qh(9zpq#o2m8bY#ZL(C(v*24FwvfmhobvsT00le`qJpRnz@@fzf7fv1Xp z>h-t{0_Uuu`nY2+?WF2Mg4b|&fb~FP$!;_C&DD5MT;4H1e_!vnDxIjYjA@hD<&zV_ zx?uZrgRQjfJ0^R>(zjG;1BAx1g7+qkygNepR9S2B{WQ1d5@{r-b&q?6y4`S(F~rQ} i;t(k^Oy6UX`SU&~+VEP~LcPf8w$44Z?vV@IQ2v!k=P~2} literal 0 HcmV?d00001 diff --git a/src/Tizen.Maps/Tizen.Maps/Area.cs b/src/Tizen.Maps/Tizen.Maps/Area.cs new file mode 100755 index 0000000..318fa98 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Area.cs @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Class representing geographical area + /// + public class Area + { + internal Interop.AreaHandle handle; + + /// + /// Constructs rectangular area + /// + /// Top left coordinate of the area + /// Bottom left coordinate of the area + /// Throws if input coordinates are invalid + /// Throws if native operation failed to allocate memory + public Area(Geocoordinates topLeft, Geocoordinates bottomRight) + { + var err = Interop.ErrorCode.InvalidParameter; + if (topLeft == null || bottomRight == null) + { + err.ThrowIfFailed("Need valid coordinates, given null"); + } + + IntPtr nativeHandle; + err = Interop.Area.CreateRectangle(topLeft.handle, bottomRight.handle, out nativeHandle); + err.ThrowIfFailed("Failed to create native rectangular area handle"); + + handle = new Interop.AreaHandle(nativeHandle); + } + + /// + /// Constructs circular area + /// + /// Coordinate for center of the area + /// Radius of the area + /// Throws if input coordinates are invalid + /// Throws if native operation failed to allocate memory + public Area(Geocoordinates center, double radius) + { + var err = Interop.ErrorCode.InvalidParameter; + if (center == null) + { + err.ThrowIfFailed("Need valid center coordinates, given null"); + } + + IntPtr nativeHandle; + err = Interop.Area.CreateCircle(center.handle, radius, out nativeHandle); + err.ThrowIfFailed("Failed to create native circular area handle"); + + handle = new Interop.AreaHandle(nativeHandle); + } + + internal Area(IntPtr nativeHandle) + { + handle = new Interop.AreaHandle(nativeHandle); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Direction.cs b/src/Tizen.Maps/Tizen.Maps/Direction.cs new file mode 100755 index 0000000..ac2e3f3 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Direction.cs @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Direction types for route maneuver + /// + public enum DirectionType + { + /// + /// Unknown direction + /// + None = Interop.RouteDirection.None, + /// + /// North direction + /// + North = Interop.RouteDirection.North, + /// + /// North-West direction + /// + NorthWest = Interop.RouteDirection.NorthWest, + /// + /// North-East direction + /// + NorthEast = Interop.RouteDirection.NorthEast, + /// + /// South direction + /// + South = Interop.RouteDirection.South, + /// + /// South-East direction + /// + SouthEast = Interop.RouteDirection.SouthEast, + /// + /// South-West direction + /// + SouthWest = Interop.RouteDirection.SouthWest, + /// + /// West direction + /// + West = Interop.RouteDirection.West, + /// + /// East direction + /// + East = Interop.RouteDirection.East, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/DistanceUnit.cs b/src/Tizen.Maps/Tizen.Maps/DistanceUnit.cs new file mode 100755 index 0000000..a1a4012 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/DistanceUnit.cs @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Allowed distance units + /// + public enum DistanceUnit + { + /// + /// Meter + /// + Meter = Interop.DistanceUnit.Meter, + /// + /// Kilometer + /// + Kilometer = Interop.DistanceUnit.Kilometer, + /// + /// Foot + /// + Foot = Interop.DistanceUnit.Foot, + /// + /// Yard + /// + Yard = Interop.DistanceUnit.Yard, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/GeocodePreference.cs b/src/Tizen.Maps/Tizen.Maps/GeocodePreference.cs new file mode 100755 index 0000000..da7786d --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/GeocodePreference.cs @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +using System; + +namespace Tizen.Maps +{ + /// + /// Preferences for Geocode service requests + /// + public class GeocodePreference + { + internal Interop.PreferenceHandle handle; + + private string _language = string.Empty; + + /// + /// Constructor for search preference + /// + public GeocodePreference() + { + IntPtr nativeHandle; + var err = Interop.Preference.Create(out nativeHandle); + if(err.ThrowIfFailed("Failed to create native preference handle")) + { + handle = new Interop.PreferenceHandle(nativeHandle); + } + } + + /// + /// Preferred language + /// + /// + /// Language should be specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code e.g. "ko-KR" + /// + public string Language + { + get + { + if (string.IsNullOrEmpty(_language)) + { + string language; + var err = Interop.Preference.GetLanguage(handle, out language); + if (err.WarnIfFailed("Failed to get language for this preference")) + { + _language = language; + } + } + return _language; + } + set + { + var err = Interop.Preference.SetLanguage(handle, value == null ? "" : value); + if (err.WarnIfFailed("Failed to set language for this preference")) + { + _language = value; + } + } + } + + /// + /// Maximum result count for a service request + /// + /// Setting negative value will not have any effect on MaxResults value + public int MaxResults + { + get + { + int _maxResults = 0; + var err = Interop.Preference.GetMaxResults(handle, out _maxResults); + err.WarnIfFailed("Failed to get max result count for this preference"); + return _maxResults; + } + set + { + var err = Interop.Preference.SetMaxResults(handle, value); + err.WarnIfFailed("Failed to set max result count for this preference"); + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/GeocodeRequest.cs b/src/Tizen.Maps/Tizen.Maps/GeocodeRequest.cs new file mode 100755 index 0000000..37c9eef --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/GeocodeRequest.cs @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Geocode request for map service + /// + public class GeocodeRequest : MapServiceRequest + { + private Interop.Service.GeocodeCallback _responseCallback; + private List _coordinateList = new List(); + private GeocodePreference _preferences = new GeocodePreference(); + + internal GeocodeRequest(MapService service, string address) : this(service, ServiceRequestType.Geocode) + { + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get co-ordinates for given address {0}", address); + errorCode = Interop.Service.Geocode(_service, address, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + + internal GeocodeRequest(MapService service, string address, Area boundry) : this(service, ServiceRequestType.GeocodeInsideArea) + { + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get co-ordinates for given address {0}", address); + errorCode = Interop.Service.GeocodeInsideArea(_service, address, boundry.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + + internal GeocodeRequest(MapService service, PlaceAddress address) : this(service, ServiceRequestType.GeocodeByStructuredAddress) + { + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get co-ordinates for given address {0}", address); + errorCode = Interop.Service.GeocodeByStructuredAddress(_service, address.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + + private GeocodeRequest(MapService service, ServiceRequestType type) : base(service, type) + { + _preferences = service.GeocodePreferences; + _responseCallback = (result, id, index, total, coordinatesHandle, userData) => + { + errorCode = result; + if (result.IsSuccess()) + { + _coordinateList.Add(new Geocoordinates(coordinatesHandle)); + if (_coordinateList.Count == total) + { + _requestTask?.TrySetResult(_coordinateList); + } + return true; + } + else + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + return false; + } + }; + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Geocoordinates.cs b/src/Tizen.Maps/Tizen.Maps/Geocoordinates.cs new file mode 100755 index 0000000..7beb857 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Geocoordinates.cs @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Class representing geographical co-ordinates + /// + public class Geocoordinates + { + internal Interop.CoordinatesHandle handle; + + /// + /// Constructs map coordinate object + /// + /// latitude value, must be between (-90.0 ~ 90.0) degrees + /// longitude value, must be between (-180.0 ~ 180.0) degrees + /// Throws if values for latitude and longitude are not valid + /// Throws if native operation failed to allocate memory + public Geocoordinates(double latitude, double longitude) + { + IntPtr nativeHandle; + var err = Interop.Coordinates.Create(latitude, longitude, out nativeHandle); + if (err.ThrowIfFailed("Failed to create native coordinate handle")) + { + handle = new Interop.CoordinatesHandle(nativeHandle); + Latitude = latitude; + Longitude = longitude; + } + } + + internal Geocoordinates(IntPtr nativeHandle) + { + double latitude; + double longitude; + handle = new Interop.CoordinatesHandle(nativeHandle); + var err = Interop.Coordinates.GetLatitudeLongitude(handle, out latitude, out longitude); + if (err.ThrowIfFailed("Failed to get coordinate value using native handle")) + { + Latitude = latitude; + Longitude = longitude; + } + } + + /// + /// Latitude for this coordinate + /// + public double Latitude { get; } + + /// + /// Longitude for this coordinate + /// + public double Longitude { get; } + + public override string ToString() + { + return string.Format("Geocoordinates(Lat: {0}, Lon: {1})", Latitude, Longitude); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/GeocoordinatesList.cs b/src/Tizen.Maps/Tizen.Maps/GeocoordinatesList.cs new file mode 100755 index 0000000..9757f67 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/GeocoordinatesList.cs @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// List of objects to be used in APIs + /// + internal class GeocoordinatesList + { + internal Interop.CoordinatesListHandle handle; + + internal GeocoordinatesList(IEnumerable coordinateList, bool ownsHandle) + { + IntPtr nativeHandle; + var err = Interop.Coordinates.ListCreate(out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for coordinate list"); + + handle = new Interop.CoordinatesListHandle(nativeHandle, ownsHandle); + foreach (var coordinates in coordinateList) + { + IntPtr clonedNativeHandle; + err = Interop.Coordinates.Clone(coordinates.handle, out clonedNativeHandle); + err.WarnIfFailed("Failed to clone native handle for coordinates"); + + Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(clonedNativeHandle); + err = Interop.Coordinates.ListAppend(handle, clonedHandle); + if (err.WarnIfFailed("Failed to add coordinate to the list")) + { + clonedHandle.ReleaseOwnership(); + } + } + } + + /// + /// Iterator for coordinates in this list + /// + internal IEnumerable Coordinates + { + get + { + List list = new List(); + Interop.Coordinates.CoordinatesCallback callback = (index, handle, userData) => + { + IntPtr clonedNativeHandle; + var result = Interop.Coordinates.Clone(handle, out clonedNativeHandle); + if (result.WarnIfFailed("Failed to add coordinate to the list")) + { + Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(clonedNativeHandle); + list.Add(new Geocoordinates(clonedHandle)); + } + return true; + }; + + var err = Interop.Coordinates.ListForeach(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get coordinates list from native handle"); + return list; + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/GestureType.cs b/src/Tizen.Maps/Tizen.Maps/GestureType.cs new file mode 100755 index 0000000..4a9ca08 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/GestureType.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + [Flags] + public enum GestureType + { + None = Interop.ViewGesture.None, + Scroll = Interop.ViewGesture.Scroll, + Zoom = Interop.ViewGesture.Zoom, + Tap = Interop.ViewGesture.Tap, + DoubleTap = Interop.ViewGesture.DoubleTap, + TwoFingerTap = Interop.ViewGesture.TwoFingerTap, + Rotate = Interop.ViewGesture.Rotate, + LongPress = Interop.ViewGesture.LongPress, + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps/MapGestureEventArgs.cs b/src/Tizen.Maps/Tizen.Maps/MapGestureEventArgs.cs new file mode 100755 index 0000000..8cccd8f --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapGestureEventArgs.cs @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using ElmSharp; + +namespace Tizen.Maps +{ + public class MapGestureEventArgs : EventArgs + { + internal static MapGestureEventArgs Create(IntPtr nativeHandle) + { + Interop.ViewGesture type; + Point screenCoordinate = new Point(); + int touchCount; + double zoomFactor; + double rotationAngle; + Geocoordinates coordinates; + + Interop.ViewEventData.GetGestureType(nativeHandle, out type); + Interop.ViewEventData.GetPosition(nativeHandle, out screenCoordinate.X, out screenCoordinate.Y); + Interop.ViewEventData.GetFingers(nativeHandle, out touchCount); + Interop.ViewEventData.GetZoomFactor(nativeHandle, out zoomFactor); + Interop.ViewEventData.GetRotationAngle(nativeHandle, out rotationAngle); + + IntPtr coordinate; + Interop.ViewEventData.GetCoordinates(nativeHandle, out coordinate); + coordinates = new Geocoordinates(coordinate); + return new MapGestureEventArgs((GestureType)type, screenCoordinate, coordinates, touchCount, zoomFactor, rotationAngle); + } + + internal MapGestureEventArgs(GestureType type, Point screenCoordinate, Geocoordinates geocoordinates, int touchCount, double zoomFactor, double rotationAngle) + { + GestureType = type; + Position = screenCoordinate; + Geocoordinates = geocoordinates; + TouchCount = touchCount; + ZoomFactor = zoomFactor; + RotationAngle = rotationAngle; + } + + public GestureType GestureType { get; } + public Point Position { get; } + public int TouchCount { get; } + public double ZoomFactor { get; } + public double RotationAngle { get; } + public Geocoordinates Geocoordinates { get; } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/MapObject.cs b/src/Tizen.Maps/Tizen.Maps/MapObject.cs new file mode 100755 index 0000000..8b761b4 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapObject.cs @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + public class MapObject + { + internal Interop.ViewObjectHandle handle; + private static Dictionary s_HandleToItemTable = new Dictionary(); + + internal MapObject(Interop.ViewObjectHandle nativeHandle) + { + handle = nativeHandle; + } + + public event EventHandler Clicked; + + public bool IsVisible + { + get + { + bool value; + Interop.ViewObject.GetVisible(handle, out value); + return value; + } + set + { + Interop.ViewObject.SetVisible(handle, value); + } + } + + internal void AddToMapObjectTable() + { + s_HandleToItemTable[handle] = this; + } + + internal void RemoveFromMapObjectTable() + { + s_HandleToItemTable.Remove(handle); + } + + internal static MapObject GetItemByHandle(IntPtr handle) + { + MapObject value; + s_HandleToItemTable.TryGetValue(handle, out value); + return value; + } + + internal void HandleClickedEvent() + { + Clicked?.Invoke(this, EventArgs.Empty); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/MapObjectEventArgs.cs b/src/Tizen.Maps/Tizen.Maps/MapObjectEventArgs.cs new file mode 100755 index 0000000..98317a8 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapObjectEventArgs.cs @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using ElmSharp; + +namespace Tizen.Maps +{ + internal class MapObjectEventArgs : EventArgs + { + internal static MapObjectEventArgs Create(IntPtr nativeHandle) + { + Interop.ViewGesture type; + Point screenCoordinate = new Point(); + int touchCount; + MapObject mapObject; + + Interop.ViewEventData.GetGestureType(nativeHandle, out type); + Interop.ViewEventData.GetPosition(nativeHandle, out screenCoordinate.X, out screenCoordinate.Y); + Interop.ViewEventData.GetFingers(nativeHandle, out touchCount); + + IntPtr nativeObjectHandle; + Interop.ViewEventData.GetObject(nativeHandle, out nativeObjectHandle); + mapObject = MapObject.GetItemByHandle(nativeObjectHandle); + return new MapObjectEventArgs((GestureType)type, screenCoordinate, touchCount, mapObject); + } + + internal MapObjectEventArgs(GestureType type, Point position, int touchCount, MapObject mapObject) + { + GestureType = type; + Position = position; + TouchCount = touchCount; + ViewObject = mapObject; + } + + public GestureType GestureType { get; } + public Point Position { get; } + public int TouchCount { get; } + public MapObject ViewObject { get; } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/MapObjectType.cs b/src/Tizen.Maps/Tizen.Maps/MapObjectType.cs new file mode 100755 index 0000000..ab491d5 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapObjectType.cs @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + internal enum MapObjectType + { + Marker, + Overlay, + Polygon, + Polyline, + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps/MapService.cs b/src/Tizen.Maps/Tizen.Maps/MapService.cs new file mode 100755 index 0000000..87aee1f --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapService.cs @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Tizen.Maps +{ + /// + /// Map service class for service request + /// + public partial class MapService : IDisposable + { + internal Interop.ServiceHandle handle; + + internal PlaceFilter _filter = new PlaceFilter(); + internal GeocodePreference _geocodePreference = new GeocodePreference(); + internal PlaceSearchPreference _placePreference = new PlaceSearchPreference(); + internal RouteSearchPreference _routePreference = new RouteSearchPreference(); + + private static List s_providers; + private string _serviceProvider; + private string _serviceProviderKey; + + /// + /// Creates a new Maps Service object for given service provider + /// + /// Name of map service provider + /// Key string provided by map service provider + /// Throws if native operation failed to allocate memory, connect to service + /// Throws if user does not have privilege to access this API + public MapService(string serviceProvider, string serviceProviderKey) + { + IntPtr nativeHandle; + var err = Interop.Service.Create(serviceProvider, out nativeHandle); + if (err.ThrowIfFailed("Failed to create native service handle")) + { + handle = new Interop.ServiceHandle(nativeHandle); + _serviceProvider = serviceProvider; + ProviderKey = serviceProviderKey; + } + } + + /// + /// List of available map service providers + /// + public static IEnumerable Providers + { + get + { + if (s_providers != null) return s_providers; + + s_providers = new List(); + Interop.Service.ProviderInfoCallback callback = (mapsProvider, userData) => + { + s_providers.Add(mapsProvider); + return true; + }; + var err = Interop.Service.ForeachProvider(callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get map service providers list"); + + return s_providers; + } + } + + /// + /// Name of map service provider + /// + public string Provider { get { return _serviceProvider; } } + + + /// + /// Key for map service provider + /// + public string ProviderKey + { + get + { + return _serviceProviderKey; + } + set + { + var err = Interop.Service.SetProviderKey(handle, value); + if (err.WarnIfFailed("Failed to set service provider key")) + { + _serviceProviderKey = value; + } + } + } + + /// + /// Filter used for place search result + /// + public PlaceFilter PlaceSearchFilter + { + get + { + return _filter; + } + set + { + _filter = value; + } + } + + /// + /// Search preferences used for Geocode/ ReverseGeocode request + /// + public GeocodePreference GeocodePreferences + { + get + { + return _geocodePreference; + } + set + { + _geocodePreference = value; + } + } + + /// + /// Search preferences used for search request + /// + public PlaceSearchPreference PlaceSearchPreferences + { + get + { + return _placePreference; + } + set + { + _placePreference = value; + } + } + + /// + /// Search preferences used for search request + /// + public RouteSearchPreference RouteSearchPreferences + { + get + { + return _routePreference; + } + set + { + _routePreference = value; + } + } + + /// + /// Gets the user's consent to use maps data + /// + /// true if user agreed that the application can use maps data, false otherwise + public static async Task RequestUserConsent(string provider) + { + TaskCompletionSource tcs = new TaskCompletionSource(); + Interop.Service.RequestUserConsentCallback cb = (consented, serviceProvider, userData) => + { + tcs.TrySetResult(consented); + }; + + var err = Interop.Service.RequestUserConsent(provider, cb, IntPtr.Zero); + if (err.IsFailed()) + { + tcs.TrySetException(err.GetException("Failed to get user consent")); + } + return await tcs.Task.ConfigureAwait(false); + } + + /// + /// Checks if the Maps Service supports given request + /// + /// request type to be checked + /// true if the Maps Service supports a request, false otherwise + public bool IsSupported(ServiceRequestType type) + { + bool result; + var err = Interop.Service.ProviderIsServiceSupported(handle, (Interop.ServiceType)type, out result); + err.WarnIfFailed(string.Format("Failed to get if {0} is supported", type)); + return (err.IsSuccess()) ? result : false; + } + + /// + /// Checks if the Maps Service supports given data feature + /// + /// data feature to be checked + /// true if the Maps Service supports a data feature, false otherwise + public bool IsSupported(ServiceData data) + { + bool result; + var err = Interop.Service.ProviderIsDataSupported(handle, (Interop.ServiceData)data, out result); + err.WarnIfFailed(string.Format("Failed to get if {0} data is supported", data)); + return (err.IsSuccess()) ? result : false; + } + + /// + /// Creates gGeocode search request for given free-formed address string + /// + /// Free-formed address + /// Returns GeocodeRequest object created with address string + public GeocodeRequest CreateGeocodeRequest(string address) + { + return new GeocodeRequest(this, address); + } + + /// + /// Creates geocode search request for given free-formed address string, within the specified boundary + /// + /// Free-formed address + /// Interested area + /// Returns GeocodeRequest object created with address string and specified boundary + public GeocodeRequest CreateGeocodeRequest(string address, Area boundary) + { + return new GeocodeRequest(this, address, boundary); + } + + /// + /// Creates geocode search request for given structured address + /// + /// address of interest + /// Returns GeocodeRequest object created with structured address + public GeocodeRequest CreateGeocodeRequest(PlaceAddress address) + { + return new GeocodeRequest(this, address); + } + + /// + /// Creates reverse geocode search request for given latitude and longitude + /// + /// Latitude for location of interest + /// Longitude for location of interest + /// Returns ReverseGeocodeRequest object created with location coordinates + public ReverseGeocodeRequest CreateReverseGeocodeRequest(double latitude, double longitute) + { + return new ReverseGeocodeRequest(this, latitude, longitute); + } + + /// + /// Creates reverse geocode search request for given position coordinates list + /// + /// Coordinates list with [2 ~ 100] coordinates + /// Returns MultiReverseGeocodeRequest object created with list of location coordinates + public MultiReverseGeocodeRequest CreateMultiReverseGeocodeRequest(IEnumerable coordinates) + { + return new MultiReverseGeocodeRequest(this, coordinates); + } + + /// + /// Creates route search request for origin and destination points + /// + /// starting point + /// destination + /// Returns RouteSearchRequest object created with origin and destination coordinates + public RouteSearchRequest CreateRouteSearchRequest(Geocoordinates from, Geocoordinates to) + { + return new RouteSearchRequest(this, from, to); + } + + /// + /// Creates place search request for specified search radius around a given coordinates position + /// + /// Interested position + /// Search radius + /// Returns PlaceSearchRequest object created with location coordinates and search radius + public PlaceSearchRequest CreatePlaceSearchRequest(Geocoordinates position, int distance) + { + return new PlaceSearchRequest(this, position, distance); + } + + /// + /// Creates place search for places within specified boundary + /// + /// Interested area + /// Returns PlaceSearchRequest object created with specified boundary + public PlaceSearchRequest CreatePlaceSearchRequest(Area boundary) + { + return new PlaceSearchRequest(this, boundary); + } + + /// + /// Creates place search for free formed address within boundary + /// + /// Free-formed address + /// Interested area + /// Returns PlaceSearchRequest object created with address string and specified boundary + public PlaceSearchRequest CreatePlaceSearchRequest(string address, Area boundary) + { + return new PlaceSearchRequest(this, address, boundary); + } + + #region IDisposable Support + private bool disposedValue = false; + protected virtual void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + //_filter.Dispose(); + //_geocodePreference.Dispose(); + //_placePreference.Dispose(); + //_routePreference.Dispose(); + } + handle.Dispose(); + disposedValue = true; + } + } + + public void Dispose() + { + Dispose(true); + } + #endregion + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/MapServiceRequest.cs b/src/Tizen.Maps/Tizen.Maps/MapServiceRequest.cs new file mode 100755 index 0000000..1863a18 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapServiceRequest.cs @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Tizen.Maps +{ + /// + /// Base class for map service request + /// + /// + public abstract class MapServiceRequest + { + protected TaskCompletionSource> _requestTask; + protected string errMessage; + protected int? _requestID; + protected ServiceRequestType _type; + + internal Action startExecutionAction; + internal Interop.ErrorCode errorCode; + internal Interop.ServiceHandle _service; + + /// + /// Creates map service request + /// + /// map service object + /// Request type + internal MapServiceRequest(MapService service, ServiceRequestType type) + { + _service = service.handle; + _type = type; + } + + /// + /// Sends request to map service provider + /// + /// Response from map service provider + /// Throws if request is canceled + /// Throws if native operation failed + public async Task> GetResponseAsync() + { + if (_requestTask == null || _requestTask.Task.IsCanceled) + { + _requestTask = new TaskCompletionSource>(); + startExecutionAction(); + await _requestTask.Task; + } + errorCode.WarnIfFailed(errMessage); + return await _requestTask.Task; + } + + /// + /// Cancel this map service request + /// + public void Cancel() + { + if (_requestTask?.Task.IsCompleted == false) + { + _requestTask?.SetCanceled(); + if (_requestID != null) + { + var err = Interop.Service.CancelRequest(_service, (int)_requestID); + err.ThrowIfFailed(string.Format("Unable to cancel service request, Type: {0}, ID: {1}", _type, _requestID)); + } + + errorCode = Interop.ErrorCode.Canceled; + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/MapTypes.cs b/src/Tizen.Maps/Tizen.Maps/MapTypes.cs new file mode 100755 index 0000000..06b3cba --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapTypes.cs @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + public enum MapTypes + { + Normal = Interop.ViewType.Normal, + Satellite = Interop.ViewType.Satellite, + Terrain = Interop.ViewType.Terrain, + Hybrid = Interop.ViewType.Hybrid, + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps/MapView.cs b/src/Tizen.Maps/Tizen.Maps/MapView.cs new file mode 100755 index 0000000..a37301d --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MapView.cs @@ -0,0 +1,492 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using ElmSharp; +using Layout = ElmSharp.Layout; +using EvasObject = ElmSharp.EvasObject; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + public class MapView : Layout + { + internal Interop.ViewHandle handle; + private Interop.ServiceHandle _service; + + private HashSet _children = new HashSet(); + + private Interop.View.ViewOnEventCallback _gestureEventCallback; + private Interop.View.ViewOnEventCallback _objectEventCallback; + private Interop.View.ViewOnEventCallback _viewReadyEventCallback; + + private event EventHandler _scrolledEventHandler; + private event EventHandler _zoomedEventHandler; + private event EventHandler _tappedEventHandler; + private event EventHandler _doubleTappedEventHandler; + private event EventHandler _twoFingerTappedEventHandler; + private event EventHandler _rotatedEventHandler; + private event EventHandler _longPressedEventHandler; + private event EventHandler _viewReadyEventHandler; + + public MapView(EvasObject parent, MapService service) : base(parent) + { + IntPtr nativeHandle; + var err = Interop.View.Create(service.handle, this, out nativeHandle); + err.ThrowIfFailed("Failed to create native map view handle"); + + handle = new Interop.ViewHandle(nativeHandle); + _service = service.handle; + + Console.WriteLine($"MapView Created: ServiceHandle: {(IntPtr)_service}, ViewHandle: {(IntPtr)handle}"); + + // We need to keep Gesture Tap event enabled for object event to work + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Tap, true); + SetObjectEventCallback(); + } + + public event EventHandler Scrolled + { + add + { + SetGestureEventCallback(); + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Scroll, true); + _scrolledEventHandler += value; + } + remove + { + _scrolledEventHandler -= value; + if (_scrolledEventHandler == null) + { + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Scroll, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler ZoomChanged + { + add + { + SetGestureEventCallback(); + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Zoom, true); + _zoomedEventHandler += value; + } + remove + { + _zoomedEventHandler -= value; + if (_zoomedEventHandler == null) + { + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Zoom, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler Clicked + { + add + { + SetGestureEventCallback(); + //Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Tap, true); + _tappedEventHandler += value; + } + remove + { + _tappedEventHandler -= value; + if (_tappedEventHandler == null) + { + //Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Tap, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler DoubleClicked + { + add + { + SetGestureEventCallback(); + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.DoubleTap, true); + _doubleTappedEventHandler += value; + } + remove + { + _doubleTappedEventHandler -= value; + if (_doubleTappedEventHandler == null) + { + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.DoubleTap, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler TwoFingerPressed + { + add + { + SetGestureEventCallback(); + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.TwoFingerTap, true); + _twoFingerTappedEventHandler += value; + } + remove + { + _twoFingerTappedEventHandler -= value; + if (_twoFingerTappedEventHandler == null) + { + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.TwoFingerTap, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler Rotated + { + add + { + SetGestureEventCallback(); + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Rotate, true); + _rotatedEventHandler += value; + } + remove + { + _rotatedEventHandler -= value; + if (_rotatedEventHandler == null) + { + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.Rotate, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler LongPressed + { + add + { + SetGestureEventCallback(); + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.LongPress, true); + _longPressedEventHandler += value; + } + remove + { + _longPressedEventHandler -= value; + if (_longPressedEventHandler == null) + { + Interop.View.SetGestureEnabled(handle, Interop.ViewGesture.LongPress, false); + UnsetGestureEventCallback(); + } + } + } + + public event EventHandler ViewReady + { + add + { + SetViewReadyEventCallback(); + _viewReadyEventHandler += value; + } + remove + { + _viewReadyEventHandler -= value; + UnsetGestureEventCallback(); + } + } + + public int ZoomLevel + { + get + { + int value; + Interop.View.GetZoomLevel(handle, out value); + return value; + } + set + { + Interop.View.SetZoomLevel(handle, value); + } + } + + public int MinimumZoomLevel + { + get + { + int value; + Interop.View.GetMinZoomLevel(handle, out value); + return value; + } + set + { + Interop.View.SetMinZoomLevel(handle, value); + } + } + + public int MaximumZoomLevel + { + get + { + int value; + Interop.View.GetMaxZoomLevel(handle, out value); + return value; + } + set + { + Interop.View.SetMaxZoomLevel(handle, value); + } + } + + public double Orientation + { + get + { + double value; + Interop.View.GetOrientation(handle, out value); + return value; + } + set + { + Interop.View.SetOrientation(handle, value); + } + } + + public MapTypes MapType + { + get + { + Interop.ViewType value; + Interop.View.GetType(handle, out value); + return (MapTypes)value; + } + set + { + Interop.View.SetType(handle, (Interop.ViewType)value); + } + } + + public bool BuildingsEnabled + { + get + { + bool value; + Interop.View.GetBuildingsEnabled(handle, out value); + return value; + } + set + { + Interop.View.SetBuildingsEnabled(handle, value); + } + } + + public bool TrafficEnabled + { + get + { + bool value; + Interop.View.GetTrafficEnabled(handle, out value); + return value; + } + set + { + Interop.View.SetTrafficEnabled(handle, value); + } + } + + public bool PublicTransitEnabled + { + get + { + bool value; + Interop.View.GetPublicTransitEnabled(handle, out value); + return value; + } + set + { + Interop.View.SetPublicTransitEnabled(handle, value); + } + } + + public bool ScalebarEnabled + { + get + { + bool value; + Interop.View.GetScalebarEnabled(handle, out value); + return value; + } + set + { + Interop.View.SetScalebarEnabled(handle, value); + } + } + + public string Language + { + get + { + string value; + Interop.View.GetLanguage(handle, out value); + return value; + } + set + { + Interop.View.SetLanguage(handle, value); + } + } + + public Geocoordinates Center + { + get + { + IntPtr coordinateHandle; + Interop.View.GetCenter(handle, out coordinateHandle); + return new Geocoordinates(coordinateHandle); + } + set + { + Geocoordinates geocoordinate = value; + Interop.View.SetCenter(handle, geocoordinate.handle); + } + } + + public IEnumerable Children + { + get + { + return _children; + } + } + + public Point GeolocationToScreen(Geocoordinates coordinates) + { + Point screenCoordinates = new Point(); + Geocoordinates geocoordinate = coordinates; + Interop.View.GeolocationToScreen(handle, geocoordinate.handle, out screenCoordinates.X, out screenCoordinates.Y); + return screenCoordinates; + } + + public Geocoordinates ScreenToGeolocation(Point screenCoordinates) + { + IntPtr coordinateHandle; + Interop.View.ScreenToGeolocation(handle, screenCoordinates.X, screenCoordinates.Y, out coordinateHandle); + return new Geocoordinates(coordinateHandle); + } + + public void Add(MapObject child) + { + child.handle.ReleaseOwnership(); + _children.Add(child); + child.AddToMapObjectTable(); + Interop.View.AddObject(handle, child.handle); + } + + public void Remove(MapObject child) + { + _children.Remove(child); + child.RemoveFromMapObjectTable(); + Interop.View.RemoveObject(handle, child.handle); + } + + public void RemoveAll() + { + foreach (var child in _children) + { + child.RemoveFromMapObjectTable(); + } + _children.Clear(); + Interop.View.RemoveAllObjects(handle); + } + + public void CaptureSnapshot(SnapshotType type, int quality, string path) + { + var err = Interop.ViewSnapshot.ViewCaptureSnapshot(handle, (Interop.ViewSnapshotFormatType)type, quality, path); + err.ThrowIfFailed("Failed to create snapshot for the view"); + } + + private void SetGestureEventCallback() + { + if (_gestureEventCallback == null) + { + _gestureEventCallback = (type, eventData, userData) => + { + if (type != Interop.ViewEventType.Gesture) return; + var eventArg = MapGestureEventArgs.Create(eventData); + switch (eventArg.GestureType) + { + case GestureType.Scroll: _scrolledEventHandler?.Invoke(this, eventArg); break; + case GestureType.Zoom: _zoomedEventHandler?.Invoke(this, eventArg); break; + case GestureType.Tap: _tappedEventHandler?.Invoke(this, eventArg); break; + case GestureType.DoubleTap: _doubleTappedEventHandler?.Invoke(this, eventArg); break; + case GestureType.TwoFingerTap: _twoFingerTappedEventHandler?.Invoke(this, eventArg); break; + case GestureType.Rotate: _rotatedEventHandler?.Invoke(this, eventArg); break; + case GestureType.LongPress: _longPressedEventHandler?.Invoke(this, eventArg); break; + } + }; + Interop.View.SetEventCb(handle, Interop.ViewEventType.Gesture, _gestureEventCallback, IntPtr.Zero); + } + } + + private void UnsetGestureEventCallback() + { + if (_scrolledEventHandler != null || _zoomedEventHandler != null + || _tappedEventHandler != null || _doubleTappedEventHandler != null + || _twoFingerTappedEventHandler != null || _rotatedEventHandler != null + || _longPressedEventHandler != null) + { + return; + } + + Interop.View.UnsetEventCb(handle, Interop.ViewEventType.Gesture); + _gestureEventCallback = null; + } + + private void SetObjectEventCallback() + { + if (_objectEventCallback == null) + { + _objectEventCallback = (type, eventData, userData) => + { + if (type != Interop.ViewEventType.Object) return; + var eventArg = MapObjectEventArgs.Create(eventData); + switch (eventArg.GestureType) + { + case GestureType.Tap: eventArg.ViewObject.HandleClickedEvent(); break; + } + }; + Interop.View.SetEventCb(handle, Interop.ViewEventType.Object, _objectEventCallback, IntPtr.Zero); + } + } + + private void SetViewReadyEventCallback() + { + if (_viewReadyEventCallback == null) + { + _viewReadyEventCallback = (type, eventData, userData) => + { + _viewReadyEventHandler?.Invoke(this, EventArgs.Empty); + }; + Interop.View.SetEventCb(handle, Interop.ViewEventType.Ready, _viewReadyEventCallback, IntPtr.Zero); + } + } + + private void UnsetViewReadyEventCallback() + { + if (_viewReadyEventHandler == null) + { + Interop.View.UnsetEventCb(handle, Interop.ViewEventType.Ready); + _viewReadyEventCallback = null; + } + } + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps/Marker.cs b/src/Tizen.Maps/Tizen.Maps/Marker.cs new file mode 100755 index 0000000..27090e5 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Marker.cs @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using ElmSharp; + +namespace Tizen.Maps +{ + public class Marker : MapObject + { + internal Marker(Interop.ViewObjectHandle nativeHandle) : base(nativeHandle) + { + } + + internal Marker(Geocoordinates coordinates, string imagePath, Interop.ViewMarkerType type) : this(CreateNativeHandle(coordinates, imagePath, type)) + { + var err = Interop.ErrorCode.InvalidParameter; + if (coordinates == null || imagePath == null) + { + err.ThrowIfFailed("given coordinates or imagePath is null"); + } + } + + public Geocoordinates Position + { + get + { + IntPtr nativeHandle; + Interop.ViewObject.MarkerGetCoordinates(handle, out nativeHandle); + return new Geocoordinates(nativeHandle); + } + set + { + // Marker takes ownership of the native handle. + IntPtr nativeHandle; + var err = Interop.Coordinates.Clone(value.handle, out nativeHandle); + err.WarnIfFailed("Failed to clone native handle for coordinates"); + + Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle); + err = Interop.ViewObject.MarkerSetCoordinates(handle, clonedHandle); + if (err.WarnIfFailed("Failed to set coordinates to marker")) + { + clonedHandle.ReleaseOwnership(); + } + } + } + + public string ImagePath + { + get + { + string value; + Interop.ViewObject.MarkerGetImageFile(handle, out value); + return value; + } + set + { + Interop.ViewObject.MarkerSetImageFile(handle, value); + } + } + + public Size MarkerSize + { + get + { + int w, h; + Interop.ViewObject.MarkerGetSize(handle, out w, out h); + return new Size(w, h); + } + set + { + Interop.ViewObject.MarkerResize(handle, value.Width, value.Height); + } + } + + public int ZOrder + { + get + { + int value; + Interop.ViewObject.MarkerGetZOrder(handle, out value); + return value; + } + set + { + Interop.ViewObject.MarkerSetZOrder(handle, value); + } + } + + public void Resize(Size newSize) + { + MarkerSize = newSize; + } + + public void Move(Geocoordinates newPosition) + { + Position = newPosition; + } + + private static Interop.ViewObjectHandle CreateNativeHandle(Geocoordinates coordinates, string imagePath, Interop.ViewMarkerType type) + { + if (coordinates == null || imagePath == null) return new Interop.ViewObjectHandle(IntPtr.Zero); + + IntPtr nativeHandle; + var err = Interop.Coordinates.Clone(coordinates.handle, out nativeHandle); + err.WarnIfFailed("Failed to clone native handle for coordinates"); + + Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle); + err = Interop.ViewObject.CreateMarker(clonedHandle, imagePath, type, out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for marker"); + + clonedHandle.ReleaseOwnership(); + return new Interop.ViewObjectHandle(nativeHandle); + } + } + + public class Pin : Marker + { + public Pin(Geocoordinates coordinates, string imagePath) : base(coordinates, imagePath, Interop.ViewMarkerType.Pin) + { + } + } + + public class Sticker : Marker + { + public Sticker(Geocoordinates coordinates, string imagePath) : base(coordinates, imagePath, Interop.ViewMarkerType.Sticker) + { + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/MultiReverseGeocodeRequest.cs b/src/Tizen.Maps/Tizen.Maps/MultiReverseGeocodeRequest.cs new file mode 100755 index 0000000..c6b9f5e --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/MultiReverseGeocodeRequest.cs @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Multiple Reverse geocode Request for Tizen map service + /// + public class MultiReverseGeocodeRequest : MapServiceRequest + { + private Interop.Service.MultiReverseGeocodeCallback _responseCallback; + private List _addressesList = new List(); + private GeocodePreference _preferences; + + internal MultiReverseGeocodeRequest(MapService service, IEnumerable coordinates) : base(service, ServiceRequestType.ReverseGeocode) + { + var coordinateList = new GeocoordinatesList(coordinates, true); + _preferences = service.GeocodePreferences; + _responseCallback = (result, id, total, addressListHandle, userData) => + { + errorCode = result; + if (result.IsSuccess()) + { + var addressList = new PlaceAddressList(addressListHandle); + addressList.handle.ReleaseOwnership(); + _addressesList = addressList.Addresses as List; + _requestTask?.TrySetResult(_addressesList); + return true; + } + else + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + return false; + } + }; + + startExecutionAction = new Action(() => + { + int requestID; + errMessage = "Failed to get address list for given co-ordinate list"; + errorCode = Interop.Service.MultiReverseGeocode(_service, coordinateList.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Overlay.cs b/src/Tizen.Maps/Tizen.Maps/Overlay.cs new file mode 100755 index 0000000..1540e0c --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Overlay.cs @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using EvasObject = ElmSharp.EvasObject; + +namespace Tizen.Maps +{ + public class Overlay : MapObject + { + private EvasObject _containedObject; + + public Overlay(Geocoordinates coordinates, EvasObject objectToContain) : this(coordinates, objectToContain, Interop.ViewOverlayType.Normal) + { + } + + internal Overlay(Interop.ViewObjectHandle nativeHandle) : base(nativeHandle) + { + } + + internal Overlay(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type) : base(CreateNativeHandle(coordinates, objectToContain, type)) + { + var err = Interop.ErrorCode.InvalidParameter; + if (coordinates == null || objectToContain == null) + { + err.ThrowIfFailed("given coordinates or parent evas object is null"); + } + + _containedObject = objectToContain; + } + + public Geocoordinates Coordinates + { + get + { + IntPtr nativeHandle; + Interop.ViewObject.OverlayGetCoordinates(handle, out nativeHandle); + return new Geocoordinates(nativeHandle); + } + set + { + // Overlay takes ownership of the native handle. + IntPtr nativeHandle; + var err = Interop.Coordinates.Clone(value.handle, out nativeHandle); + err.WarnIfFailed("Failed to clone native handle for coordinates"); + + Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle); + err = Interop.ViewObject.OverlaySetCoordinates(handle, clonedHandle); + if (err.WarnIfFailed("Failed to set coordinates to overlay")) + { + clonedHandle.ReleaseOwnership(); + } + } + } + + public int MinimumZoomLevel + { + get + { + int value; + Interop.ViewObject.OverlayGetMinZoomLevel(handle, out value); + return value; + } + set + { + Interop.ViewObject.OverlaySetMinZoomLevel(handle, value); + } + } + + public int MaximumZoomLevel + { + get + { + int value; + Interop.ViewObject.OverlayGetMaxZoomLevel(handle, out value); + return value; + } + set + { + Interop.ViewObject.OverlaySetMaxZoomLevel(handle, value); + } + } + + private static Interop.ViewObjectHandle CreateNativeHandle(Geocoordinates coordinates, EvasObject objectToContain, Interop.ViewOverlayType type) + { + if (coordinates == null || objectToContain == null) return new Interop.ViewObjectHandle(IntPtr.Zero); + + IntPtr nativeHandle; + var err = Interop.Coordinates.Clone(coordinates.handle, out nativeHandle); + err.ThrowIfFailed("Failed to clone native handle for coordinates"); + + Interop.CoordinatesHandle clonedHandle = new Interop.CoordinatesHandle(nativeHandle); + err = Interop.ViewObject.CreateOverlay(clonedHandle, objectToContain, type, out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for Overlay"); + + clonedHandle.ReleaseOwnership(); + return new Interop.ViewObjectHandle(nativeHandle); + } + } + + public class BubbleOverlay : Overlay + { + public BubbleOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Bubble) + { + } + } + + public class BoxOverlay : Overlay + { + public BoxOverlay(Geocoordinates coordinates, EvasObject objectToContain) : base(coordinates, objectToContain, Interop.ViewOverlayType.Box) + { + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Place.cs b/src/Tizen.Maps/Tizen.Maps/Place.cs new file mode 100755 index 0000000..ded800b --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Place.cs @@ -0,0 +1,344 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Place information, used in Place Discovery and Search + /// + public class Place + { + internal Interop.PlaceHandle handle; + + private string _id; + private string _name; + private string _uri; + private Geocoordinates _location; + private int _distance; + private PlaceAddress _address; + private PlaceRating _rating; + + private Dictionary _properties; + private List _categories = new List(); + private List _attributes = new List(); + private List _contacts = new List(); + private List _editorials = new List(); + private List _images = new List(); + private List _reviews = new List(); + + private PlaceLink _supplier; + private PlaceLink _related; + + internal Place(IntPtr nativeHandle) + { + handle = new Interop.PlaceHandle(nativeHandle); + + var err = Interop.Place.GetDistance(handle, out _distance); + err.WarnIfFailed("Failed to get distance for this place"); + + IntPtr supplierHandle; + err = Interop.Place.GetSupplierLink(handle, out supplierHandle); + if (err.WarnIfFailed("Failed to get supplier link for this image")) + { + _supplier = new PlaceLink(supplierHandle); + } + + IntPtr relatedHandle; + err = Interop.Place.GetRelatedLink(handle, out relatedHandle); + if (err.WarnIfFailed("Failed to get related link for this image")) + { + _related = new PlaceLink(relatedHandle); + } + } + + /// + /// Place ID + /// + public string Id + { + get + { + if (string.IsNullOrEmpty(_id)) + { + var err = Interop.Place.GetId(handle, out _id); + err.WarnIfFailed("Failed to get id for this place"); + } + return _id; + } + } + + /// + /// Place Name + /// + public string Name + { + get + { + if (string.IsNullOrEmpty(_name)) + { + var err = Interop.Place.GetName(handle, out _name); + err.WarnIfFailed("Failed to get name for this place"); + } + return _name; + } + } + + /// + /// Place URI + /// + public string Uri + { + get + { + if (string.IsNullOrEmpty(_uri)) + { + var err = Interop.Place.GetUri(handle, out _uri); + err.WarnIfFailed("Failed to get URI for this place"); + } + return _uri; + } + } + + /// + /// Place location + /// + public Geocoordinates Location + { + get + { + if (_location == null) + { + IntPtr locationHandle; + var err = Interop.Place.GetLocation(handle, out locationHandle); + if (err.WarnIfFailed("Failed to get coordinates for this place")) + { + _location = new Geocoordinates(locationHandle); + } + } + return _location; + } + } + + public int Distance { get { return _distance; } } + + /// + /// Place address + /// + public PlaceAddress Address + { + get + { + if (_address == null) + { + IntPtr addressHandle; + var err = Interop.Place.GetAddress(handle, out addressHandle); + if (err.WarnIfFailed("Failed to get address for this place")) + { + _address = new PlaceAddress(addressHandle); + } + } + return _address; + } + } + + /// + /// Rating for the place + /// + public PlaceRating Rating + { + get + { + if (_rating == null) + { + IntPtr ratingHandle; + var err = Interop.Place.GetRating(handle, out ratingHandle); + if (err.WarnIfFailed("Failed to get rating for this place")) + { + _rating = new PlaceRating(ratingHandle); + } + } + return _rating; + } + } + + /// + /// All properties attached with this place + /// + public IDictionary Properties + { + get + { + if (_properties != null) return _properties; + _properties = new Dictionary(); + Interop.Place.PropertiesCallback callback = (index, total, key, value, userData) => + { + _properties[key] = value; + return true; + }; + + var err = Interop.Place.ForeachProperty(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all properties for this place"); + + return _properties; + } + } + + /// + /// All categories attached with this place + /// + public IEnumerable Categories + { + get + { + if (_categories != null) return _categories; + _categories = new List(); + Interop.Place.CategoriesCallback callback = (index, total, categoryHandle, userData) => + { + _categories.Add(new PlaceCategory(categoryHandle)); + return true; + }; + + var err = Interop.Place.ForeachCategory(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all categories for this place"); + + return _categories; + } + } + + /// + /// All attributes attached with this place + /// + public IEnumerable Attributes + { + get + { + if (_attributes != null) return _attributes; + _attributes = new List(); + Interop.Place.AttributesCallback callback = (index, total, attributeHandle, userData) => + { + _attributes.Add(new PlaceAttribute(attributeHandle)); + return true; + }; + + var err = Interop.Place.ForeachAttribute(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all attributes for this place"); + + return _attributes; + } + } + + /// + /// All contacts attached with this place + /// + public IEnumerable Contacts + { + get + { + if (_contacts != null) return _contacts; + _contacts = new List(); + Interop.Place.ContactsCallback callback = (index, total, contactHandle, userData) => + { + _contacts.Add(new PlaceContact(contactHandle)); + return true; + }; + + var err = Interop.Place.ForeachContact(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all contacts for this place"); + + return _contacts; + } + } + + /// + /// All editorials attached with this place + /// + public IEnumerable Editorials + { + get + { + if (_editorials != null) return _editorials; + _editorials = new List(); + Interop.Place.EditorialsCallback callback = (index, total, editorialHandle, userData) => + { + _editorials.Add(new PlaceEditorial(editorialHandle)); + return true; + }; + + var err = Interop.Place.ForeachEditorial(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all editorials for this place"); + + return _editorials; + } + } + + /// + /// All images attached with this place + /// + public IEnumerable Images + { + get + { + if (_images != null) return _images; + _images = new List(); + Interop.Place.ImagesCallback callback = (index, total, imageHandle, userData) => + { + _images.Add(new PlaceImage(imageHandle)); + return true; + }; + + var err = Interop.Place.ForeachImage(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all images for this place"); + + return _images; + } + } + + /// + /// All reviews attached with this place + /// + public IEnumerable Reviews + { + get + { + if (_reviews != null) return _reviews; + _reviews = new List(); + Interop.Place.ReviewsCallback callback = (index, total, reviewHandle, userData) => + { + _reviews.Add(new PlaceReview(reviewHandle)); + return true; + }; + + var err = Interop.Place.ForeachReview(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all reviews for this place"); + + return _reviews; + } + } + + /// + /// Place image supplier link + /// + public PlaceLink Supplier { get { return _supplier; } } + + /// + /// Place image related link + /// + public PlaceLink Related { get { return _related; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceAddress.cs b/src/Tizen.Maps/Tizen.Maps/PlaceAddress.cs new file mode 100755 index 0000000..0422785 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceAddress.cs @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Address information for the map point used in Geocode and Reverse Geocode requests. + /// + public class PlaceAddress + { + internal Interop.AddressHandle handle; + private string _building; + private string _city; + private string _country; + private string _countryCode; + private string _county; + private string _district; + private string _freetext; + private string _postalCode; + private string _state; + private string _street; + + /// + /// Construct map address object + /// + /// Throws if native operation failed to allocate memory + public PlaceAddress() + { + IntPtr nativeHandle; + var err = Interop.Address.Create(out nativeHandle); + err.ThrowIfFailed("Failed to create native address handle"); + + handle = new Interop.AddressHandle(nativeHandle); + } + + internal PlaceAddress(IntPtr nativeHandle) + { + handle = new Interop.AddressHandle(nativeHandle); + } + + /// + /// Building number for this address + /// + public string Building + { + get + { + if (string.IsNullOrEmpty(_building)) + { + var err = Interop.Address.GetBuildingNumber(handle, out _building); + err.WarnIfFailed("Failed to get building number"); + } + return _building == null ? string.Empty : _building; + } + set + { + var err = Interop.Address.SetBuildingNumber(handle, value); + if (err.WarnIfFailed("Failed to set building number")) + { + _building = value; + } + } + } + + /// + /// City name for this address + /// + public string City + { + get + { + if (string.IsNullOrEmpty(_city)) + { + var err = Interop.Address.GetCity(handle, out _city); + err.WarnIfFailed("Failed to get city"); + } + return _city == null ? string.Empty : _city; + } + set + { + var err = Interop.Address.SetCity(handle, value); + if (err.WarnIfFailed("Failed to set city")) + { + _city = value; + } + } + } + + /// + /// Country name for this address + /// + public string Country + { + get + { + if (string.IsNullOrEmpty(_country)) + { + var err = Interop.Address.GetCountry(handle, out _country); + err.WarnIfFailed("Failed to get country"); + } + return _country == null ? string.Empty : _country; + } + set + { + var err = Interop.Address.SetCountry(handle, value); + if (err.WarnIfFailed("Failed to set country")) + { + _country = value; + } + } + } + + /// + /// Country code for this address + /// + public string CountryCode + { + get + { + if (string.IsNullOrEmpty(_countryCode)) + { + var err = Interop.Address.GetCountryCode(handle, out _countryCode); + err.WarnIfFailed("Failed to get country code"); + } + return _countryCode == null ? string.Empty : _countryCode; + } + set + { + var err = Interop.Address.SetCountryCode(handle, value); + if (err.WarnIfFailed("Failed to set country code")) + { + _countryCode = value; + } + } + } + + /// + /// County for this address + /// + public string County + { + get + { + if (string.IsNullOrEmpty(_county)) + { + var err = Interop.Address.GetCounty(handle, out _county); + err.WarnIfFailed("Failed to get county"); + } + return _county == null ? string.Empty : _county; + } + set + { + var err = Interop.Address.SetCounty(handle, value); + if (err.WarnIfFailed("Failed to set county")) + { + _county = value; + } + } + } + + /// + /// District name for this address + /// + public string District + { + get + { + if (string.IsNullOrEmpty(_district)) + { + var err = Interop.Address.GetDistrict(handle, out _district); + err.WarnIfFailed("Failed to get district"); + } + return _district == null ? string.Empty : _district; + } + set + { + var err = Interop.Address.SetDistrict(handle, value); + if (err.WarnIfFailed("Failed to set district")) + { + _district = value; + } + } + } + + /// + /// Free text associated with this address + /// + public string Freetext + { + get + { + if (string.IsNullOrEmpty(_freetext)) + { + var err = Interop.Address.GetFreetext(handle, out _freetext); + err.WarnIfFailed("Failed to get free-text"); + } + return _freetext == null ? string.Empty : _freetext; + } + set + { + var err = Interop.Address.SetFreetext(handle, value); + if (err.WarnIfFailed("Failed to set free-text")) + { + _freetext = value; + } + } + } + + /// + /// Postal code for this address + /// + public string PostalCode + { + get + { + if (string.IsNullOrEmpty(_postalCode)) + { + var err = Interop.Address.GetPostalCode(handle, out _postalCode); + err.WarnIfFailed("Failed to get postal code"); + } + return _postalCode == null ? string.Empty : _postalCode; + } + set + { + var err = Interop.Address.SetPostalCode(handle, value); + if (err.WarnIfFailed("Failed to set postal code")) + { + _postalCode = value; + } + } + } + + /// + /// State name for this address + /// + public string State + { + get + { + if (string.IsNullOrEmpty(_state)) + { + var err = Interop.Address.GetState(handle, out _state); + err.WarnIfFailed("Failed to get state"); + } + return _state == null ? string.Empty : _state; + } + set + { + var err = Interop.Address.SetState(handle, value); + if (err.WarnIfFailed("Failed to set state")) + { + _state = value; + } + } + } + + /// + /// Street name for this address + /// + public string Street + { + get + { + if (string.IsNullOrEmpty(_street)) + { + var err = Interop.Address.GetStreet(handle, out _street); + err.WarnIfFailed("Failed to get street"); + } + return _street == null ? string.Empty : _street; + } + set + { + var err = Interop.Address.SetStreet(handle, value); + if (err.WarnIfFailed("Failed to set street")) + { + _street = value; + } + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceAddressList.cs b/src/Tizen.Maps/Tizen.Maps/PlaceAddressList.cs new file mode 100755 index 0000000..7b757cd --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceAddressList.cs @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// List of objects to be used in APIs + /// + internal class PlaceAddressList + { + internal Interop.AddressListHandle handle; + private List _list; + + /// + /// Construct map address list object + /// + /// Throws if native operation failed to allocate memory + public PlaceAddressList() + { + IntPtr nativeHandle; + var err = Interop.Address.ListCreate(out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for address list"); + + handle = new Interop.AddressListHandle(nativeHandle); + } + + internal PlaceAddressList(IntPtr nativeHandle) + { + handle = new Interop.AddressListHandle(nativeHandle); + } + + /// + /// Iterator for addresses in this list + /// + public IEnumerable Addresses + { + get + { + if (_list == null) + { + _list = new List(); + Interop.Address.AddressCallback callback = (index, handle, userData) => + { + IntPtr cloned; + // we need to clone handle as it will not be there once this callback returns + if (Interop.Address.Clone(handle, out cloned).IsSuccess()) + { + _list.Add(new PlaceAddress(cloned)); + } + return true; + }; + + var err = Interop.Address.ListForeach(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get address list from native handle"); + } + return _list; + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceAttribute.cs b/src/Tizen.Maps/Tizen.Maps/PlaceAttribute.cs new file mode 100755 index 0000000..451f2a2 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceAttribute.cs @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Attributes information, used in Place Discovery and Search requests + /// + public class PlaceAttribute + { + private string _id; + private string _label; + private string _text; + + internal PlaceAttribute(IntPtr nativeHandle) + { + var handle = new Interop.PlaceAttributeHandle(nativeHandle); + var err = Interop.PlaceAttribute.GetId(handle, out _id); + err.WarnIfFailed("Failed to get id for this attribute"); + + err = Interop.PlaceAttribute.GetLabel(handle, out _label); + err.WarnIfFailed("Failed to get label for this attribute"); + + err = Interop.PlaceAttribute.GetText(handle, out _text); + err.WarnIfFailed("Failed to get text for this attribute"); + } + + /// + /// Place Attribute ID + /// + public string Id { get { return _id; } } + + /// + /// Place attribute label + /// + public string Label { get { return _label; } } + + /// + /// Place attribute text + /// + public string Text { get { return _text; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceCategory.cs b/src/Tizen.Maps/Tizen.Maps/PlaceCategory.cs new file mode 100755 index 0000000..4659c18 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceCategory.cs @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Category information, used in Place Discovery and Search requests + /// + public class PlaceCategory + { + internal Interop.PlaceCategoryHandle handle; + protected string _id; + protected string _name; + protected string _url; + + /// + /// Constructs search category object + /// + /// Throws if native operation failed to allocate memory + public PlaceCategory() + { + IntPtr nativeHandle; + var err = Interop.PlaceCategory.Create(out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for Place Category"); + + handle = new Interop.PlaceCategoryHandle(nativeHandle); + } + + internal PlaceCategory(IntPtr nativeHandle) + { + handle = new Interop.PlaceCategoryHandle(nativeHandle); + Initialize(); + } + + /// + /// ID for this category + /// + public string Id + { + get + { + return _id; + } + set + { + var err = Interop.PlaceCategory.SetId(handle, value); + if (err.WarnIfFailed("Failed to set id for place category")) + { + _id = value; + } + } + } + + /// + /// Name for this category + /// + public string Name + { + get + { + return _name; + } + set + { + var err = Interop.PlaceCategory.SetName(handle, value); + if (err.WarnIfFailed("Failed to set name for place category")) + { + _name = value; + } + } + } + + /// + /// URL for this category + /// + public string Url + { + get + { + return _url; + } + set + { + var err = Interop.PlaceCategory.SetUrl(handle, value); + if (err.WarnIfFailed("Failed to set URL for place category")) + { + _url = value; + } + } + } + + internal void Initialize() + { + var err = Interop.PlaceCategory.GetId(handle, out _id); + err.WarnIfFailed("Failed to get id for place category"); + + err = Interop.PlaceCategory.GetName(handle, out _name); + err.WarnIfFailed("Failed to get name for place category"); + + err = Interop.PlaceCategory.GetUrl(handle, out _url); + err.WarnIfFailed("Failed to get URL for place category"); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceContact.cs b/src/Tizen.Maps/Tizen.Maps/PlaceContact.cs new file mode 100755 index 0000000..b3cf10f --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceContact.cs @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Contact information, used in Place Discovery and Search requests + /// + public class PlaceContact + { + private string _label; + private string _type; + private string _value; + + internal PlaceContact(IntPtr nativeHandle) + { + var handle = new Interop.PlaceContactHandle(nativeHandle); + var err = Interop.PlaceContact.GetLabel(handle, out _label); + err.WarnIfFailed("Failed to get label for this contact"); + + err = Interop.PlaceContact.GetType(handle, out _type); + err.WarnIfFailed("Failed to get type for this contact"); + + err = Interop.PlaceContact.GetValue(handle, out _value); + err.WarnIfFailed("Failed to get value for this contact"); + } + + /// + /// Place contact label + /// + public string Id { get { return _label; } } + + /// + /// Place contact type + /// + public string Label { get { return _type; } } + + /// + /// Place contact value + /// + public string Value { get { return _value; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceEditorial.cs b/src/Tizen.Maps/Tizen.Maps/PlaceEditorial.cs new file mode 100755 index 0000000..b77515e --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceEditorial.cs @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Editorial information, used in Place Discovery and Search requests + /// + public class PlaceEditorial + { + private string _description; + private string _language; + private PlaceMedia _media; + + internal PlaceEditorial(IntPtr nativeHandle) + { + var handle = new Interop.PlaceEditorialHandle(nativeHandle); + var err = Interop.PlaceEditorial.GetDescription(handle, out _description); + err.WarnIfFailed("Failed to get description for this editorial"); + + err = Interop.PlaceEditorial.GetLanguage(handle, out _language); + err.WarnIfFailed("Failed to get language for this editorial"); + + IntPtr mediaHandle; + err = Interop.PlaceEditorial.GetMedia(handle, out mediaHandle); + if (err.WarnIfFailed("Failed to get media for this editorial")) + { + _media = new PlaceMedia(mediaHandle); + } + } + + /// + /// Place editorial description + /// + public string Description { get { return _description; } } + + /// + /// Place editorial language + /// + public string Language { get { return _language; } } + + /// + /// Place editorial value + /// + public PlaceMedia Media { get { return _media; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceFilter.cs b/src/Tizen.Maps/Tizen.Maps/PlaceFilter.cs new file mode 100755 index 0000000..b649d66 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceFilter.cs @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Filter information, used in Place Discovery and Search requests + /// + public class PlaceFilter + { + internal Interop.PlaceFilterHandle handle; + private string _address; + private PlaceCategory _category; + private string _keyword; + private string _name; + + /// + /// Constructs new place filter + /// + /// Throws if native operation failed to allocate memory + public PlaceFilter() + { + IntPtr nativeHandle; + var err = Interop.PlaceFilter.Create(out nativeHandle); + err.ThrowIfFailed("Failed to create native place filter handle"); + + handle = new Interop.PlaceFilterHandle(nativeHandle); + } + + /// + /// Filter string for place addresses + /// + public string Address + { + get + { + if (string.IsNullOrEmpty(_address)) + { + var err = Interop.PlaceFilter.GetPlaceAddress(handle, out _address); + err.WarnIfFailed("Failed to get filter string for place addresses"); + } + return _address; + } + set + { + var err = Interop.PlaceFilter.SetPlaceAddress(handle, value); + if (err.WarnIfFailed("Failed to set filter string for place addresses")) + { + _address = value; + } + } + } + + /// + /// Category filter for places + /// + public PlaceCategory Category + { + get + { + if (_category == null) + { + IntPtr nativeHandle; + var err = Interop.PlaceFilter.GetCategory(handle, out nativeHandle); + if (err.WarnIfFailed("Failed to get category filter for places")) + { + _category = new PlaceCategory(nativeHandle); + } + } + return _category; + } + set + { + var err = Interop.PlaceFilter.SetCategory(handle, value.handle); + if (err.WarnIfFailed("Failed to set category filter for places")) + { + _category = value; + } + } + } + + /// + /// Filter keyword for place + /// + public string Keyword + { + get + { + if (string.IsNullOrEmpty(_keyword)) + { + var err = Interop.PlaceFilter.GetKeyword(handle, out _keyword); + err.WarnIfFailed("Failed to get filter keywords for places"); + } + return _keyword; + } + set + { + var err = Interop.PlaceFilter.SetKeyword(handle, value); + if (err.WarnIfFailed("Failed to set filter keywords for places")) + { + _keyword = value; + } + } + } + + /// + /// Filter string for place names + /// + public string Name + { + get + { + if (string.IsNullOrEmpty(_name)) + { + var err = Interop.PlaceFilter.GetPlaceName(handle, out _name); + err.WarnIfFailed("Failed to get filter string for place names"); + } + return _name; + } + set + { + var err = Interop.PlaceFilter.SetPlaceName(handle, value); + if (err.WarnIfFailed("Failed to set filter string for place names")) + { + _name = value; + } + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceImage.cs b/src/Tizen.Maps/Tizen.Maps/PlaceImage.cs new file mode 100755 index 0000000..272bbdb --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceImage.cs @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Image information, used in Place Discovery and Search requests + /// + public class PlaceImage + { + private string _id; + private string _url; + private int _width; + private int _height; + private PlaceLink _userLink; + private PlaceMedia _media; + + internal PlaceImage(IntPtr nativeHandle) + { + var handle = new Interop.PlaceImageHandle(nativeHandle); + var err = Interop.PlaceImage.GetId(handle, out _id); + err.WarnIfFailed("Failed to get id for this image"); + + err = Interop.PlaceImage.GetUrl(handle, out _url); + err.WarnIfFailed("Failed to get URL for this image"); + + err = Interop.PlaceImage.GetWidth(handle, out _width); + err.WarnIfFailed("Failed to get width for this image"); + + err = Interop.PlaceImage.GetHeight(handle, out _height); + err.WarnIfFailed("Failed to get height for this image"); + + IntPtr userHandle; + err = Interop.PlaceImage.GetUserLink(handle, out userHandle); + if (err.WarnIfFailed("Failed to get user link for this image")) + { + _userLink = new PlaceLink(userHandle); + } + + IntPtr mediaHandle; + err = Interop.PlaceImage.GetMedia(handle, out mediaHandle); + if (err.WarnIfFailed("Failed to get media for this image")) + { + _media = new PlaceMedia(mediaHandle); + } + } + + /// + /// Place image Id + /// + public string Id { get { return _id; } } + + /// + /// Place image URL + /// + public string Url { get { return _url; } } + + /// + /// Place image width + /// + public int Width { get { return _width; } } + + /// + /// Place image height + /// + public int Height { get { return _height; } } + + /// + /// Place image user link + /// + public PlaceLink UserLink { get { return _userLink; } } + + /// + /// Place image media + /// + public PlaceMedia ImageMedia { get { return _media; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceLink.cs b/src/Tizen.Maps/Tizen.Maps/PlaceLink.cs new file mode 100755 index 0000000..dade418 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceLink.cs @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Link Object information, used in Place Discovery and Search requests + /// + public class PlaceLink + { + private string _id; + private string _name; + private string _string; + private string _type; + + internal PlaceLink(IntPtr nativeHandle) + { + var handle = new Interop.PlaceLinkObjectHandle(nativeHandle); + + var err = Interop.PlaceLinkObject.GetId(handle, out _id); + err.WarnIfFailed("Failed to get id for this link"); + + err = Interop.PlaceLinkObject.GetName(handle, out _name); + err.WarnIfFailed("Failed to get name for this link"); + + err = Interop.PlaceLinkObject.GetString(handle, out _string); + err.WarnIfFailed("Failed to get string for this link"); + + err = Interop.PlaceLinkObject.GetType(handle, out _type); + err.WarnIfFailed("Failed to get type for this link"); + } + + /// + /// Place link ID + /// + public string Id { get { return _id; } } + + /// + /// Place link name + /// + public string Name { get { return _name; } } + + /// + /// Place link string + /// + public string LinkString { get { return _string; } } + + /// + /// Place link type + /// + public string Type { get { return _type; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceList.cs b/src/Tizen.Maps/Tizen.Maps/PlaceList.cs new file mode 100755 index 0000000..e92bd5d --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceList.cs @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// List of objects to be used in APIs + /// + internal class PlaceList + { + internal Interop.PlaceListHandle handle; + private List _list; + + internal PlaceList(IntPtr nativeHandle) + { + handle = new Interop.PlaceListHandle(nativeHandle); + Interop.Place.PlaceCallback callback = (index, placeHandle, userData) => + { + _list.Add(new Place(placeHandle)); + return true; + }; + + var err = Interop.Place.ListForeach(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to create address to the list from native handle"); + } + + /// + /// Iterator for addresses in this list + /// + public IEnumerable Places + { + get + { + if (_list == null) + { + _list = new List(); + Interop.Place.PlaceCallback callback = (index, handle, userData) => + { + _list.Add(new Place(handle)); + return true; + }; + + var err = Interop.Place.ListForeach(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get place list from native handle"); + } + return _list; + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceMedia.cs b/src/Tizen.Maps/Tizen.Maps/PlaceMedia.cs new file mode 100755 index 0000000..22a19ec --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceMedia.cs @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Media information, used in Place Discovery and Search requests + /// + public class PlaceMedia + { + private string _attribution; + private PlaceLink _supplier; + private PlaceLink _via; + + internal PlaceMedia(IntPtr nativeHandle) + { + var handle = new Interop.PlaceMediaHandle(nativeHandle); + + var err = Interop.PlaceMedia.GetAttribution(handle, out _attribution); + err.WarnIfFailed("Failed to get attribution for this media"); + + IntPtr supplierHandle; + err = Interop.PlaceMedia.GetSupplier(handle, out supplierHandle); + if (err.WarnIfFailed("Failed to get supplier object for this media")) + { + _supplier = new PlaceLink(supplierHandle); + } + + IntPtr viaHandle; + err = Interop.PlaceMedia.GetVia(handle, out viaHandle); + if (err.WarnIfFailed("Failed to get via object for this media")) + { + _via = new PlaceLink(viaHandle); + } + } + + /// + /// Place media attribution + /// + public string Attribution { get { return _attribution; } } + + /// + /// Place media supplier value + /// + public PlaceLink Supplier { get { return _supplier; } } + + /// + /// Place media via value + /// + public PlaceLink Via { get { return _via; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceRating.cs b/src/Tizen.Maps/Tizen.Maps/PlaceRating.cs new file mode 100755 index 0000000..2d31e41 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceRating.cs @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Rating information, used in Place Discovery and Search requests + /// + public class PlaceRating + { + private int _count; + private double _average; + + internal PlaceRating(IntPtr nativeHandle) + { + var handle = new Interop.PlaceRatingHandle(nativeHandle); + + var err = Interop.PlaceRating.GetCount(handle, out _count); + err.WarnIfFailed("Failed to get count value for this rating"); + + err = Interop.PlaceRating.GetAverage(handle, out _average); + err.WarnIfFailed("Failed to get average value for this rating"); + } + + /// + /// Number of users rated for this rating + /// + public int UserCount { get { return _count; } } + + /// + /// Average value of user rating + /// + public double Average { get { return _average; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceReview.cs b/src/Tizen.Maps/Tizen.Maps/PlaceReview.cs new file mode 100755 index 0000000..6c1f163 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceReview.cs @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Place Review information, used in Place Discovery and Search requests + /// + public class PlaceReview + { + private DateTime _date; + private string _title; + private double _rating; + private string _description; + private string _language; + private PlaceMedia _media; + private PlaceLink _userLink; + + internal PlaceReview(IntPtr nativeHandle) + { + string date; + var handle = new Interop.PlaceReviewHandle(nativeHandle); + var err = Interop.PlaceReview.GetDate(handle, out date); + if (err.WarnIfFailed("Failed to get date for this review")) + { + if (DateTime.TryParse(date, out _date) == false) + { + Interop.ErrorCode.InvalidParameter.WarnIfFailed(string.Format("Wrong date format: {0}", date)); + } + } + + err = Interop.PlaceReview.GetTitle(handle, out _title); + err.WarnIfFailed("Failed to get title for this review"); + + err = Interop.PlaceReview.GetRating(handle, out _rating); + err.WarnIfFailed("Failed to get rating for this review"); + + err = Interop.PlaceReview.GetDescription(handle, out _description); + err.WarnIfFailed("Failed to get description for this review"); + + err = Interop.PlaceReview.GetLanguage(handle, out _language); + err.WarnIfFailed("Failed to get language for this review"); + + IntPtr mediaHandle; + err = Interop.PlaceReview.GetMedia(handle, out mediaHandle); + if (err.WarnIfFailed("Failed to get media for this review")) + { + _media = new PlaceMedia(mediaHandle); + } + + IntPtr userHandle; + err = Interop.PlaceReview.GetUserLink(handle, out userHandle); + if (err.WarnIfFailed("Failed to get user link for this review")) + { + _userLink = new PlaceLink(userHandle); + } + } + + /// + /// Time of this review + /// + public DateTime Date { get { return _date; } } + + /// + /// Title of this review + /// + public string Title { get { return _title; } } + + /// + /// Rating of this review + /// + public double Rating { get { return _rating; } } + + /// + /// Description of this review + /// + public string Description { get { return _description; } } + + /// + /// Language of this review + /// + public string Language { get { return _language; } } + + /// + /// Media attached with this review + /// + public PlaceMedia ReviewMedia { get { return _media; } } + + /// + /// User link of this review + /// + public PlaceLink UserLink { get { return _userLink; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceSearchPreference.cs b/src/Tizen.Maps/Tizen.Maps/PlaceSearchPreference.cs new file mode 100755 index 0000000..8e8cd66 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceSearchPreference.cs @@ -0,0 +1,165 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Preferences for place search requests + /// + public class PlaceSearchPreference + { + internal Interop.PreferenceHandle handle; + + private string _language = string.Empty; + private string _countryCode = string.Empty; + private Interop.DistanceUnit? _distanceUnit; + + private IDictionary _properties = new Dictionary(); + + /// + /// Constructor for search preference + /// + public PlaceSearchPreference() + { + IntPtr nativeHandle; + var err = Interop.Preference.Create(out nativeHandle); + err.WarnIfFailed("Failed to create native preference handle"); + + handle = new Interop.PreferenceHandle(nativeHandle); + } + + /// + /// Constructor for search preference + /// + public PlaceSearchPreference(IDictionary properties) : this() + { + _properties = properties; + foreach (var item in properties) + { + var err = Interop.Preference.SetProperty(handle, item.Key, item.Value); + err.WarnIfFailed(string.Format("Failed to set property: {0} = {1}", item.Key, item.Value)); + } + } + + /// + /// Distance unit + /// + public DistanceUnit Unit + { + get + { + if (_distanceUnit == null) + { + var err = Interop.Preference.GetDistanceUnit(handle, out _distanceUnit); + err.WarnIfFailed("Failed to get distance unit for this preference"); + } + return (DistanceUnit)_distanceUnit; + } + set + { + var err = Interop.Preference.SetDistanceUnit(handle, (Interop.DistanceUnit)value); + if (err.WarnIfFailed("Failed to set distance unit for this preference")) + { + _distanceUnit = (Interop.DistanceUnit)value; + } + } + } + + /// + /// Preferred language + /// + /// + /// Language should be specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code e.g. "ko-KR" + /// + public string Language + { + get + { + if (string.IsNullOrEmpty(_language)) + { + var err = Interop.Preference.GetLanguage(handle, out _language); + err.WarnIfFailed("Failed to get language for this preference"); + } + return _language; + } + set + { + var err = Interop.Preference.SetLanguage(handle, value); + if (err.WarnIfFailed("Failed to set language for this preference")) + { + _language = value; + } + } + } + + /// + /// Maximum result count for a service request + /// + public int MaxResults + { + get + { + int _maxResults = 0; + var err = Interop.Preference.GetMaxResults(handle, out _maxResults); + err.WarnIfFailed("Failed to get max result count for this preference"); + return _maxResults; + } + set + { + var err = Interop.Preference.SetMaxResults(handle, value); + err.WarnIfFailed("Failed to set max result count for this preference"); + } + } + + /// + /// Preferred country + /// + public string CountryCode + { + get + { + if (string.IsNullOrEmpty(_countryCode)) + { + var err = Interop.Preference.GetCountryCode(handle, out _countryCode); + err.WarnIfFailed("Failed to get country code for this preference"); + } + return _countryCode; + } + set + { + var err = Interop.Preference.SetCountryCode(handle, value); + if (err.WarnIfFailed("Failed to set country code for this preference")) + { + _countryCode = value; + } + } + } + + /// + /// Search properties as key value pair + /// + public IReadOnlyDictionary Properties + { + get + { + return _properties as IReadOnlyDictionary; + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/PlaceSearchRequest.cs b/src/Tizen.Maps/Tizen.Maps/PlaceSearchRequest.cs new file mode 100755 index 0000000..8cd831e --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/PlaceSearchRequest.cs @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Place search request for Tizen map service + /// + public class PlaceSearchRequest : MapServiceRequest + { + private Interop.Service.SearchPlaceCallback _responseCallback; + private List _placeList = new List(); + private PlaceFilter _filter; + private PlaceSearchPreference _preferences; + + internal PlaceSearchRequest(MapService service, Geocoordinates position, int distance) : this(service, ServiceRequestType.SearchPlace) + { + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get place list for given co-ordinate {0} and distance {1}", position, distance); + errorCode = Interop.Service.SearchPlace(_service, position.handle, distance, _filter.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + + internal PlaceSearchRequest(MapService service, Area boundary) : this(service, ServiceRequestType.SearchPlaceByArea) + { + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get place list for given boundary {0}", boundary); + errorCode = Interop.Service.SearchPlaceByArea(_service, boundary.handle, _filter.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + + internal PlaceSearchRequest(MapService service, string address, Area boundary) : this(service, ServiceRequestType.SearchPlaceByAddress) + { + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get co-ordinates for given address {0} and boundary {1}", address, boundary); + errorCode = Interop.Service.SearchPlaceByAddress(_service, address, boundary.handle, _filter.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + + private PlaceSearchRequest(MapService service, ServiceRequestType type) : base(service, type) + { + _filter = service._filter; + _preferences = service.PlaceSearchPreferences; + _responseCallback = (result, id, index, total, placeHandle, userData) => + { + errorCode = result; + if (result.IsSuccess()) + { + _placeList.Add(new Place(placeHandle)); + if (_placeList.Count == total) + { + _requestTask?.TrySetResult(_placeList); + } + return true; + } + else + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + return false; + } + }; + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Polygon.cs b/src/Tizen.Maps/Tizen.Maps/Polygon.cs new file mode 100755 index 0000000..fd3dd78 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Polygon.cs @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; + +using Color = ElmSharp.Color; + +namespace Tizen.Maps +{ + public class Polygon : MapObject + { + private List _coordinateList; + + public Polygon(IEnumerable coordinates, Color color) : base(CreateNativeHandle(coordinates, color)) + { + var err = Interop.ErrorCode.InvalidParameter; + if (coordinates == null || coordinates.Count() < 3) + { + err.ThrowIfFailed("given coordinates list should contain at least 3 coordinates"); + } + _coordinateList = coordinates.ToList(); + } + + internal Polygon(Interop.ViewObjectHandle nativeHandle) : base(nativeHandle) + { + } + + public IEnumerable Coordinates + { + get + { + if (_coordinateList == null) + { + _coordinateList = new List(); + Interop.ViewObject.CoordinatesCallback callback = (index, nativeHandle, userData) => + { + _coordinateList.Add(new Geocoordinates(nativeHandle)); + return true; + }; + Interop.ViewObject.PolygonForeachPoint(handle, callback, IntPtr.Zero); + } + return _coordinateList; + } + set + { + var coordinates = value.ToList(); + + var err = Interop.ErrorCode.InvalidParameter; + if (coordinates == null || coordinates.Count() < 3) + { + err.ThrowIfFailed("given coordinates list should contain at least 3 coordinates"); + } + + var coordinateList = new GeocoordinatesList(coordinates, false); + if (Interop.ViewObject.PolygonSetPolygon(handle, coordinateList.handle).IsSuccess()) + { + _coordinateList = coordinates; + } + } + } + + public Color FillColor + { + get + { + byte r, g, b, a; + Interop.ViewObject.PolygonGetFillColor(handle, out r, out g, out b, out a); + return new Color(r, g, b, a); + } + set + { + Interop.ViewObject.PolygonSetFillColor(handle, (byte)value.R, (byte)value.G, (byte)value.B, (byte)value.A); + } + } + + private static Interop.ViewObjectHandle CreateNativeHandle(IEnumerable coordinates, Color color) + { + if (coordinates == null || coordinates.Count() < 3) return new Interop.ViewObjectHandle(IntPtr.Zero); + + IntPtr nativeHandle; + var geocoordinateList = new GeocoordinatesList(coordinates.ToList(), false); + var err = Interop.ViewObject.CreatePolygon(geocoordinateList.handle, (byte)color.R, (byte)color.G, (byte)color.B, (byte)color.A, out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for polygon"); + return new Interop.ViewObjectHandle(nativeHandle); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Polyline.cs b/src/Tizen.Maps/Tizen.Maps/Polyline.cs new file mode 100755 index 0000000..e27357f --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Polyline.cs @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; + +using Color = ElmSharp.Color; + +namespace Tizen.Maps +{ + public class Polyline : MapObject + { + private List _coordinateList; + + public Polyline(List coordinates, Color color, int width) : base(CreateNativeHandle(coordinates, color, width)) + { + var err = Interop.ErrorCode.InvalidParameter; + if (coordinates == null || coordinates.Count() < 2) + { + err.ThrowIfFailed("given coordinates list should contain at least 2 coordinates"); + } + _coordinateList = coordinates.ToList(); + } + + internal Polyline(Interop.ViewObjectHandle nativeHandle) : base(nativeHandle) + { + } + + public IEnumerable Coordinates + { + get + { + if (_coordinateList == null) + { + _coordinateList = new List(); + Interop.ViewObject.CoordinatesCallback callback = (index, nativeHandle, userData) => + { + _coordinateList.Add(new Geocoordinates(nativeHandle)); + return true; + }; + Interop.ViewObject.PolylineForeachPoint(handle, callback, IntPtr.Zero); + } + return _coordinateList; + } + set + { + var coordinates = value.ToList(); + var err = Interop.ErrorCode.InvalidParameter; + if (coordinates == null || coordinates.Count() < 2) + { + err.ThrowIfFailed("given coordinates list should contain at least 2 coordinates"); + } + + var coordinateList = new GeocoordinatesList(coordinates, false); + if (Interop.ViewObject.PolylineSetPolyline(handle, coordinateList.handle).IsSuccess()) + { + _coordinateList = coordinates; + } + } + } + + public Color LineColor + { + get + { + byte r, g, b, a; + Interop.ViewObject.PolylineGetColor(handle, out r, out g, out b, out a); + return new Color(r, g, b, a); + } + set + { + Interop.ViewObject.PolylineSetColor(handle, (byte)value.R, (byte)value.G, (byte)value.B, (byte)value.A); + } + } + + public int Width + { + get + { + int value; + Interop.ViewObject.PolylineGetWidth(handle, out value); + return value; + } + set + { + Interop.ViewObject.PolylineSetWidth(handle, value); + } + } + + private static Interop.ViewObjectHandle CreateNativeHandle(IEnumerable coordinates, Color color, int width) + { + if (coordinates == null || coordinates.Count() < 2) return new Interop.ViewObjectHandle(IntPtr.Zero); + + IntPtr nativeHandle; + var coordinateList = new GeocoordinatesList(coordinates.ToList(), false); + var err = Interop.ViewObject.CreatePolyline(coordinateList.handle, (byte)color.R, (byte)color.G, (byte)color.B, (byte)color.A, width, out nativeHandle); + err.ThrowIfFailed("Failed to create native handle for polyline"); + return new Interop.ViewObjectHandle(nativeHandle); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/ReverseGeocodeRequest.cs b/src/Tizen.Maps/Tizen.Maps/ReverseGeocodeRequest.cs new file mode 100755 index 0000000..f40c358 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/ReverseGeocodeRequest.cs @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Reverse geocode request for Tizen map service + /// + public class ReverseGeocodeRequest : MapServiceRequest + { + private Interop.Service.ReverseGeocodeCallback _responseCallback; + private List _addressList = new List(); + private GeocodePreference _preferences; + + internal ReverseGeocodeRequest(MapService service, double latitude, double longitute) : base(service, ServiceRequestType.ReverseGeocode) + { + _preferences = service.GeocodePreferences; + _responseCallback = (result, id, index, total, addressHandle, userData) => + { + errorCode = result; + if (result.IsSuccess()) + { + _addressList.Add(new PlaceAddress(addressHandle)); + if (_addressList.Count == total) + { + _requestTask?.TrySetResult(_addressList); + } + } + else + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + }; + + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get co-ordinates for given Coordinate: {0}:{1}", latitude, longitute); + errorCode = Interop.Service.ReverseGeocode(_service, latitude, longitute, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + _requestID = requestID; + }); + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/Route.cs b/src/Tizen.Maps/Tizen.Maps/Route.cs new file mode 100755 index 0000000..255929b --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/Route.cs @@ -0,0 +1,218 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Route information, used in Route Search requests + /// + public class Route + { + internal Interop.RouteHandle handle; + private Area _bondingBox; + private Geocoordinates _destination; + private double _distance; + private long _duration; + private string _id = string.Empty; + private Geocoordinates _origin; + private List _path; + + private Dictionary _properties; + private List _segments; + private Interop.RouteTransportMode _transportMode; + private Interop.DistanceUnit _unit; + + internal Route(IntPtr nativeHandle) + { + handle = new Interop.RouteHandle(nativeHandle); + + var err = Interop.Route.GetTransportMode(handle, out _transportMode); + err.WarnIfFailed("Failed to get transport mode for the segment"); + + err = Interop.Route.GetTotalDistance(handle, out _distance); + err.WarnIfFailed("Failed to get distance for the segment"); + + err = Interop.Route.GetDistanceUnit(handle, out _unit); + err.WarnIfFailed("Failed to get distance for the segment"); + + err = Interop.Route.GetTotalDuration(handle, out _duration); + err.WarnIfFailed("Failed to get duration for the segment"); + } + + /// + /// Destination coordinates for this route + /// + public Geocoordinates Destination + { + get + { + if (_destination != null) return _destination; + + IntPtr destinationHandle; + var err = Interop.Route.GetDestination(handle, out destinationHandle); + if (err.WarnIfFailed("Failed to get destination for the route")) + { + _destination = new Geocoordinates(destinationHandle); + } + return _destination; + } + } + + /// + /// Total distance for this route + /// + public double Distance { get { return _distance; } } + + /// + /// Total duration to cover this route + /// + public double Duration { get { return _duration; } } + + public string Id + { + get + { + if (string.IsNullOrEmpty(_id)) + { + string id; + var err = Interop.Route.GetRouteId(handle, out id); + if (err.WarnIfFailed("Failed to get route id")) + { + _id = id; + } + } + return _id; + } + } + + /// + /// Transport Mode for this route + /// + public TransportMode Mode { get { return (TransportMode)_transportMode; } } + + /// + /// Origin coordinates for this route + /// + public Geocoordinates Origin + { + get + { + if (_origin != null) return _origin; + + IntPtr originHandle; + var err = Interop.Route.GetOrigin(handle, out originHandle); + if (err.WarnIfFailed("Failed to get origin for the route")) + { + _origin = new Geocoordinates(originHandle); + } + return _origin; + } + } + + /// + /// Coordinates list for this route + /// + public IEnumerable Path + { + get + { + if (_path != null) return _path; + + _path = new List(); + Interop.Route.RoutePathCallback callback = (index, total, coordinateHandle, userData) => + { + _path.Add(new Geocoordinates(coordinateHandle)); + return true; + }; + + var err = Interop.Route.ForeachPath(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get path coordinates for this route"); + return _path; + } + } + + /// + /// All properties attached with this route + /// + public IDictionary Properties + { + get + { + if (_properties != null) return _properties; + _properties = new Dictionary(); + Interop.Route.RoutePropertiesCallback callback = (index, total, key, value, userData) => + { + _properties[key] = value; + return true; + }; + var err = Interop.Route.ForeachProperty(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get all properties for this route"); + + return _properties; + } + } + + /// + /// Segment list for this route + /// + public IEnumerable Segments + { + get + { + if (_segments != null) return _segments; + + _segments = new List(); + Interop.Route.RouteSegmentCallback callback = (index, total, segmentHandle, userData) => + { + _segments.Add(new RouteSegment(segmentHandle)); + return true; + }; + + var err = Interop.Route.ForeachSegment(handle, callback, IntPtr.Zero); + err.WarnIfFailed("Failed to get path segments for this route"); + return _segments; + } + } + + /// + /// Distance unit for this route + /// + public DistanceUnit Unit { get { return (DistanceUnit)_unit; } } + + /// + /// Bounding area for this route + /// + private Area BoundingBox + { + get + { + if (_bondingBox != null) return _bondingBox; + + IntPtr areaHandle; + var err = Interop.Route.GetBoundingBox(handle, out areaHandle); + if (err.WarnIfFailed("Failed to get bonding box for the route")) + { + _bondingBox = new Area(areaHandle); + } + return _bondingBox; + } + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/RouteFeature.cs b/src/Tizen.Maps/Tizen.Maps/RouteFeature.cs new file mode 100755 index 0000000..cb50d46 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteFeature.cs @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Route features, used for route search requests + /// + public enum RouteFeature + { + /// + /// Indicates no route features (are selected) + /// + None = Interop.RouteRequestFeature.None, + /// + /// Indicates toll roads (toll gates/booths) + /// + Toll = Interop.RouteRequestFeature.Toll, + /// + /// Indicates motorway + /// + Motorway = Interop.RouteRequestFeature.MotorWay, + /// + /// Indicates a boat ferry + /// + BoatFerry = Interop.RouteRequestFeature.BoatFerry, + /// + /// Indicates rail (train) ferry + /// + RailFerry = Interop.RouteRequestFeature.RailFerry, + /// + /// Indicates public transport + /// + PublicTransit = Interop.RouteRequestFeature.PublicTransit, + /// + /// Indicates tunnel + /// + Tunnel = Interop.RouteRequestFeature.Tunnel, + /// + /// Indicates dirt road + /// + DirtRoad = Interop.RouteRequestFeature.DirtRoad, + /// + /// Indicates park + /// + Parks = Interop.RouteRequestFeature.Parks, + /// + /// Indicates a high-occupancy vehicle lane + /// + Hovlane = Interop.RouteRequestFeature.Hovlane, + /// + /// Indicates stairs + /// + Stairs = Interop.RouteRequestFeature.Stairs, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/RouteFeatureWeight.cs b/src/Tizen.Maps/Tizen.Maps/RouteFeatureWeight.cs new file mode 100755 index 0000000..f93faba --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteFeatureWeight.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Route feature weights used in route search requests + /// + public enum RouteFeatureWeight + { + /// + /// Indicates normal weighting + /// + Normal = Interop.RouteFeatureWeight.Normal, + /// + /// Indicates that a feature is preferred + /// + Prefer = Interop.RouteFeatureWeight.Prefer, + /// + /// Indicates that a feature is to be avoided + /// + Avoid = Interop.RouteFeatureWeight.Avoid, + /// + /// Indicates that soft-exclude applies to the feature + /// + SoftExclude = Interop.RouteFeatureWeight.SoftExclude, + /// + /// Indicates that the feature is to be strictly excluded + /// + StrictExclude = Interop.RouteFeatureWeight.StrictExclude, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/RouteManeuver.cs b/src/Tizen.Maps/Tizen.Maps/RouteManeuver.cs new file mode 100755 index 0000000..1b0e8fd --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteManeuver.cs @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Route Maneuver information, used in Route Search requests + /// + public class RouteManeuver + { + private Interop.RouteDirection _direction; + private Interop.RouteTurnType _turntype; + private Geocoordinates _position; + private string _road = string.Empty; + private string _instruction = string.Empty; + private string _locale = string.Empty; + private int _timeToNextInstruction; + private double _distanceToNextInstruction; + + internal RouteManeuver(IntPtr nativeHandle) + { + var handle = new Interop.RouteManeuverHandle(nativeHandle); + + var err = Interop.RouteManeuver.GetDirectionId(handle, out _direction); + err.WarnIfFailed("Failed to get direction type for this maneuver"); + + err = Interop.RouteManeuver.GetTurnType(handle, out _turntype); + err.WarnIfFailed("Failed to get turn type for this maneuver"); + + err = Interop.RouteManeuver.GetTimeToNextInstruction(handle, out _timeToNextInstruction); + err.WarnIfFailed("Failed to get time to next instruction for this maneuver"); + + err = Interop.RouteManeuver.GetDistanceToNextInstruction(handle, out _distanceToNextInstruction); + err.WarnIfFailed("Failed to get distance to next instruction for this maneuver"); + + string instruction; + err = Interop.RouteManeuver.GetInstructionText(handle, out instruction); + if (err.WarnIfFailed("Failed to get instruction text for this maneuver")) + { + _instruction = instruction; + } + + string locale; + err = Interop.RouteManeuver.GetLocale(handle, out locale); + if (err.WarnIfFailed("Failed to get locale for this maneuver")) + { + _locale = locale; + } + + string road; + err = Interop.RouteManeuver.GetRoadName(handle, out road); + if (err.WarnIfFailed("Failed to get road name for this maneuver")) + { + _road = road; + } + + IntPtr positionHandle; + err = Interop.RouteManeuver.GetPosition(handle, out positionHandle); + if (err.WarnIfFailed("Failed to get position for this maneuver")) + { + _position = new Geocoordinates(positionHandle); + } + } + + /// + /// Direction type for this maneuver + /// + public DirectionType Direction { get { return (DirectionType)_direction; } } + + /// + /// Turn type for this maneuver + /// + public TurnInstruction Turn { get { return (TurnInstruction)_turntype; } } + + /// + /// Position for this maneuver + /// + public Geocoordinates Position { get { return _position; } } + + /// + /// Name of the road for this maneuver + /// + public string Road { get { return string.IsNullOrEmpty(_road) ? "" : _road; } } + + /// + /// Instruction text for this maneuver + /// + public string Instruction { get { return string.IsNullOrEmpty(_instruction) ? "" : _instruction; } } + + /// + /// Locale for this maneuver + /// + public string Locale { get { return string.IsNullOrEmpty(_locale) ? "" : _locale; } } + + /// + /// Time to next instruction for this maneuver + /// + public int TimeToNextInstruction { get { return _timeToNextInstruction; } } + + /// + /// Distance to next instruction for this maneuver + /// + public double DistanceToNextInstruction { get { return _distanceToNextInstruction; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/RouteOptimization.cs b/src/Tizen.Maps/Tizen.Maps/RouteOptimization.cs new file mode 100755 index 0000000..bde76fd --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteOptimization.cs @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Allowed route optimization option used in route search requests + /// + public enum RouteOptimization + { + /// + /// Search for fastest routes + /// + Fastest = Interop.RouteOptimization.Fastest, + /// + /// Search for shortest routes (car mode only) + /// + Shortest = Interop.RouteOptimization.Shortest, + /// + /// Search for most economic routes (car mode only) + /// + Economic = Interop.RouteOptimization.Economic, + /// + /// Search for most scenic routes + /// + Scenic = Interop.RouteOptimization.Scenic, + /// + /// Search for most fastest routes now, based on current traffic condition + /// + FastestNow = Interop.RouteOptimization.FastestNow, + /// + /// Search for direct drive routes + /// + DirectDrive = Interop.RouteOptimization.DirectDrive, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/RouteSearchPreference.cs b/src/Tizen.Maps/Tizen.Maps/RouteSearchPreference.cs new file mode 100755 index 0000000..5704afc --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteSearchPreference.cs @@ -0,0 +1,196 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; + +namespace Tizen.Maps +{ + /// + /// Preferences for route search requests + /// + public class RouteSearchPreference + { + internal Interop.PreferenceHandle handle; + + private Interop.DistanceUnit? _distanceUnit; + private Interop.RouteOptimization? _routeOptimization; + private Interop.RouteTransportMode? _transportMode; + private Interop.RouteFeatureWeight? _featureWeight; + private Interop.RouteRequestFeature? _requestFeature; + private bool? _searchAlternativeRoutes; + + /// + /// Constructor for search preference + /// + public RouteSearchPreference() + { + IntPtr nativeHandle; + var err = Interop.Preference.Create(out nativeHandle); + err.ThrowIfFailed("Failed to create native preference handle"); + + handle = new Interop.PreferenceHandle(nativeHandle); + } + + internal RouteSearchPreference(Interop.PreferenceHandle handle) + { + this.handle = handle; + } + + /// + /// Distance unit + /// + public DistanceUnit Unit + { + get + { + if (_distanceUnit == null) + { + var err = Interop.Preference.GetDistanceUnit(handle, out _distanceUnit); + err.WarnIfFailed("Failed to get distance unit for this preference"); + } + return (DistanceUnit)_distanceUnit; + } + set + { + var err = Interop.Preference.SetDistanceUnit(handle, (Interop.DistanceUnit)value); + if (err.WarnIfFailed("Failed to set distance unit for this preference")) + { + _distanceUnit = (Interop.DistanceUnit)value; + } + } + } + + /// + /// Selected route optimization + /// + public RouteOptimization Optimization + { + get + { + if (_routeOptimization == null) + { + var err = Interop.Preference.GetRouteOptimization(handle, out _routeOptimization); + err.WarnIfFailed("Failed to get route optimization for this preference"); + } + return (RouteOptimization)_routeOptimization; + } + set + { + var err = Interop.Preference.SetRouteOptimization(handle, (Interop.RouteOptimization)value); + if (err.WarnIfFailed("Failed to set route optimization for this preference")) + { + _routeOptimization = (Interop.RouteOptimization)value; + } + } + } + + /// + /// Route transport mode + /// + public TransportMode Mode + { + get + { + if (_transportMode == null) + { + var err = Interop.Preference.GetRouteTransportMode(handle, out _transportMode); + err.WarnIfFailed("Failed to get route transport mode for this preference"); + } + return (TransportMode)_transportMode; + } + set + { + var err = Interop.Preference.SetRouteTransportMode(handle, (Interop.RouteTransportMode)value); + if (err.WarnIfFailed("Failed to set route transport mode for this preference")) + { + _transportMode = (Interop.RouteTransportMode)value; + } + } + } + + /// + /// Route feature weight + /// + public RouteFeatureWeight RouteFeatureWeight + { + get + { + if (_featureWeight == null) + { + var err = Interop.Preference.GetRouteFeatureWeight(handle, out _featureWeight); + err.WarnIfFailed("Failed to get route feature weight for this preference"); + } + return (RouteFeatureWeight)_featureWeight; + } + set + { + var err = Interop.Preference.SetRouteFeatureWeight(handle, (Interop.RouteFeatureWeight)value); + if (err.WarnIfFailed("Failed to set route feature weight for this preference")) + { + _featureWeight = (Interop.RouteFeatureWeight)value; + } + } + } + + /// + /// Route feature + /// + public RouteFeature RouteFeature + { + get + { + if (_requestFeature == null) + { + var err = Interop.Preference.GetRouteFeature(handle, out _requestFeature); + err.WarnIfFailed("Failed to get route feature for this preference"); + } + return (RouteFeature)_requestFeature; + } + set + { + var err = Interop.Preference.SetRouteFeature(handle, (Interop.RouteRequestFeature)value); + if (err.WarnIfFailed("Failed to set route request feature for this preference")) + { + _requestFeature = (Interop.RouteRequestFeature)value; + } + } + } + + /// + /// Indicate if search for alternative routes is enabled. + /// + public bool SearchAlternativeRoutes + { + get + { + if (_searchAlternativeRoutes == null) + { + var err = Interop.Preference.GetRouteAlternativesEnabled(handle, out _searchAlternativeRoutes); + err.WarnIfFailed("Failed to get preference for alternative route search"); + } + return (bool)_searchAlternativeRoutes; + } + set + { + var err = Interop.Preference.SetRouteAlternativesEnabled(handle, value); + if (err.WarnIfFailed("Failed to enable alternative route searches")) + { + _searchAlternativeRoutes = value; + } + } + } + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps/RouteSearchRequest.cs b/src/Tizen.Maps/Tizen.Maps/RouteSearchRequest.cs new file mode 100755 index 0000000..2e95560 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteSearchRequest.cs @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Tizen.Maps +{ + /// + /// Route search request for Tizen map service requests + /// + public class RouteSearchRequest : MapServiceRequest + { + private Interop.Service.SearchRouteCallback _responseCallback; + private List _routeList = new List(); + + + private Geocoordinates _from; + private Geocoordinates _to; + private List _waypoints = new List(); + private RouteSearchPreference _preferences; + + internal RouteSearchRequest(MapService service, Geocoordinates from, Geocoordinates to) : this(service, ServiceRequestType.SearchByEndPoint) + { + _from = from; + _to = to; + startExecutionAction = new Action(() => + { + int requestID; + errMessage = string.Format("Failed to get route list for given origin {0} and destination {1}", _from, _to); + if (_waypoints?.Count == 0) + { + _type = ServiceRequestType.SearchByEndPoint; + errorCode = Interop.Service.SearchRoute(_service, _from.handle, _to.handle, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + } + else + { + _type = ServiceRequestType.SearchWithWaypoints; + + var waypoints = GetCoordinateListForWaypoints(); + errorCode = Interop.Service.SearchRouteWaypoints(_service, waypoints, waypoints.Length, _preferences.handle, _responseCallback, IntPtr.Zero, out requestID); + if (errorCode.IsFailed() && errorCode != Interop.ErrorCode.Canceled) + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + } + } + _requestID = requestID; + }); + } + + + private RouteSearchRequest(MapService service, ServiceRequestType type) : base(service, type) + { + _preferences = service.RouteSearchPreferences; + _responseCallback = (result, id, index, total, routeHandle, userData) => + { + errorCode = result; + if (result.IsSuccess()) + { + _routeList.Add(new Route(routeHandle)); + if (_routeList.Count == total) + { + _requestTask?.TrySetResult(_routeList); + } + return true; + } + else + { + _requestTask?.TrySetException(errorCode.GetException(errMessage)); + return false; + } + }; + } + + /// + /// List of way-points to cover between origin and destination + /// + public IEnumerable Waypoints + { + get + { + return _waypoints; + } + set + { + _waypoints = value.ToList(); + } + } + + private IntPtr[] GetCoordinateListForWaypoints() + { + var waypoints = new IntPtr[_waypoints.Count + 2]; + waypoints[0] = _from.handle; + for (int i = 0; i < _waypoints.Count; ++i) + { + waypoints[i + 1] = _waypoints[i].handle; + } + waypoints[waypoints.Length - 1] = _to.handle; + return waypoints; + } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/RouteSegment.cs b/src/Tizen.Maps/Tizen.Maps/RouteSegment.cs new file mode 100755 index 0000000..37b491a --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/RouteSegment.cs @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +using System; +using System.Collections.Generic; + +namespace Tizen.Maps +{ + /// + /// Place Segment information, used in Route Search requests + /// + public class RouteSegment + { + internal Interop.RouteSegmentHandle handle; + private Area _bondingBox; + private Geocoordinates _destination; + private double _distance; + private long _duration; + private List _manuevers; + private Geocoordinates _origin; + private List _path; + + internal RouteSegment(IntPtr nativeHandle) + { + handle = new Interop.RouteSegmentHandle(nativeHandle); + + var err = Interop.RouteSegment.GetDistance(handle, out _distance); + err.WarnIfFailed("Failed to get distance for the segment"); + + err = Interop.RouteSegment.GetDuration(handle, out _duration); + err.WarnIfFailed("Failed to get duration for the segment"); + + IntPtr areaHandle; + err = Interop.RouteSegment.GetBoundingBox(handle, out areaHandle); + if (err.WarnIfFailed("Failed to get bonding box for the segment")) + { + _bondingBox = new Area(areaHandle); + } + + IntPtr originHandle; + err = Interop.RouteSegment.GetOrigin(handle, out originHandle); + if (err.WarnIfFailed("Failed to get origin for the segment")) + { + _origin = new Geocoordinates(originHandle); + } + + IntPtr destinationHandle; + err = Interop.RouteSegment.GetDestination(handle, out destinationHandle); + if (err.WarnIfFailed("Failed to get destination for the segment")) + { + _destination = new Geocoordinates(destinationHandle); + } + + _manuevers = new List(); + Interop.RouteSegment.SegmentManeuverCallback maneuvarCallback = (index, total, maneuverHandle, userData) => + { + _manuevers.Add(new RouteManeuver(maneuverHandle)); + return true; + }; + + err = Interop.RouteSegment.ForeachManeuver(handle, maneuvarCallback, IntPtr.Zero); + err.WarnIfFailed("Failed to get path maneuver for this segment"); + + _path = new List(); + Interop.RouteSegment.SegmentPathCallback pathcallback = (index, total, coordinateHandle, userData) => + { + _path.Add(new Geocoordinates(coordinateHandle)); + return true; + }; + + err = Interop.RouteSegment.ForeachPath(handle, pathcallback, IntPtr.Zero); + err.WarnIfFailed("Failed to get path coordinates for this segment"); + } + + /// + /// Origin coordinates for this segment + /// + public Geocoordinates Origin { get { return _origin; } } + + /// + /// Destination coordinates for this segment + /// + public Geocoordinates Destination { get { return _destination; } } + + /// + /// Total distance for this segment + /// + public double Distance { get { return _distance; } } + + /// + /// Total duration to cover this segment + /// + public double Duration { get { return _duration; } } + + /// + /// Maneuver list for this segment path + /// + public IEnumerable Maneuvers { get { return _manuevers; } } + + /// + /// Coordinates list for this segment path + /// + public IEnumerable Path { get { return _path; } } + + /// + /// Bounding area for this segment + /// + private Area BoundingBox { get { return _bondingBox; } } + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/ServiceData.cs b/src/Tizen.Maps/Tizen.Maps/ServiceData.cs new file mode 100755 index 0000000..151ea7f --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/ServiceData.cs @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Features available in the Map Service + /// + public enum ServiceData + { + /// + /// Indicates availability of address value in the Place data + /// + PlaceAddress = Interop.ServiceData.PlaceAddress, + /// + /// Indicates availability of rating value in the Place data + /// + PlaceRating = Interop.ServiceData.PlaceRating, + /// + /// Indicates availability of place category list in the Place data + /// + PlaceCategories = Interop.ServiceData.PlaceCategories, + /// + /// Indicates availability of place attribute list in the Place data + /// + PlaceAttributes = Interop.ServiceData.PlaceAttributes, + /// + /// Indicates availability of place contact list in the Place data + /// + PlaceContacts = Interop.ServiceData.PlaceContacts, + /// + /// Indicates availability of place editorial list in the Place data + /// + PlaceEditorials = Interop.ServiceData.PlaceEditorials, + /// + /// Indicates availability of place review list in the Place data + /// + PlaceReviews = Interop.ServiceData.PlaceReviews, + /// + /// Indicates availability of place image in Place the data + /// + PlaceImage = Interop.ServiceData.PlaceImage, + /// + /// Indicates availability of place supplier link value in the Place data + /// + PlaceSupplier = Interop.ServiceData.PlaceSupplier, + /// + /// Indicates availability of related place link in the Place data + /// + PlaceRelated = Interop.ServiceData.PlaceRelated, + + /// + /// Indicates that the Route Data Structure is defined as a Path (a list of geographical coordinates) + /// + RouteAsPath = Interop.ServiceData.RoutePath, + /// + /// Indicates that the Route Data Structure is defined as a list of Segments while each segment is defined as a Path + /// + SegmentsAsPath = Interop.ServiceData.RouteSegmentsPath, + /// + /// Indicates that the Route Data Structure is defined as a list of Segments while each segment is defined as a list of Maneuvers + /// + SegmentsAsManeuvers = Interop.ServiceData.RouteSegmentsManeuvers, + + /// + /// Indicates availability of traffic information on the Map + /// + ViewTraffic = Interop.ServiceData.ViewTraffic, + /// + /// Indicates availability of public transit information on the Map + /// + ViewPublicTransit = Interop.ServiceData.ViewPublicTransit, + /// + /// Indicates availability of 3D building drawable on the Map + /// + ViewBuilding = Interop.ServiceData.ViewBuilding, + /// + /// Indicates availability of scale bar on the Map + /// + ViewScalebar = Interop.ServiceData.ViewScalebar, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/ServiceRequestType.cs b/src/Tizen.Maps/Tizen.Maps/ServiceRequestType.cs new file mode 100755 index 0000000..ea79b5e --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/ServiceRequestType.cs @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Service Requests available in the Maps Service + /// + public enum ServiceRequestType + { + /// + /// Service request to get position for a given free-formed address string is allowed + /// + Geocode = Interop.ServiceType.Geocode, + /// + /// Service request to get position for a given address, within the specified bounding , is allowed + /// + GeocodeInsideArea = Interop.ServiceType.GeocodeInsideArea, + /// + /// Service request to get position for a given is allowed + /// + GeocodeByStructuredAddress = Interop.ServiceType.GeocodeByStructuredAddress, + /// + /// Service request to get for a given is allowed + /// + ReverseGeocode = Interop.ServiceType.ReverseGeocode, + /// + /// Service request to get for a given is allowed + /// + MultiReverseGeocode = Interop.ServiceType.MultiReverseGeocode, + + /// + /// Service request to query information for a given is allowed + /// + SearchPlace = Interop.ServiceType.SearchPlace, + /// + /// Service request to query information for a given is allowed + /// + SearchPlaceByArea = Interop.ServiceType.SearchPlaceByArea, + /// + /// Service request to query information for a given free-formed address string is allowed + /// + SearchPlaceByAddress = Interop.ServiceType.SearchPlaceByAddress, + /// + /// Service request to query information list for all places in a given is allowed + /// + SearchPlaceList = Interop.ServiceType.SearchPlaceList, + /// + /// Service request to get detailed information for a given is allowed + /// + SearchGetPlaceDetails = Interop.ServiceType.SearchGetPlaceDetails, + + /// + /// Service request to query information from a given origin and destination is allowed + /// + SearchByEndPoint = Interop.ServiceType.SearchRoute, + /// + /// Service request to query information passing through specified way-points is allowed + /// + SearchWithWaypoints = Interop.ServiceType.SearchRouteWaypoints, + + /// + /// Map view service is allowed + /// + View = Interop.ServiceType.View, + /// + /// Map view snapshot service is allowed + /// + ViewSnapshot = Interop.ServiceType.ViewSnapshot, + + /// + /// Canceling a request is allowed + /// + CancelRequest = Interop.ServiceType.CancelRequest, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/SnapshotType.cs b/src/Tizen.Maps/Tizen.Maps/SnapshotType.cs new file mode 100755 index 0000000..88fce00 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/SnapshotType.cs @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Enumeration for snapshot file formats + /// + public enum SnapshotType + { + /// + /// BMP file format + /// + BMP = Interop.ViewSnapshotFormatType.ViewSnapshotBmp, + /// + /// JPEG file format + /// + JPEG = Interop.ViewSnapshotFormatType.ViewSnapshotJpeg, + } +} \ No newline at end of file diff --git a/src/Tizen.Maps/Tizen.Maps/TransportMode.cs b/src/Tizen.Maps/Tizen.Maps/TransportMode.cs new file mode 100755 index 0000000..92195ea --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/TransportMode.cs @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Route types + /// + public enum TransportMode + { + /// + /// Route is to be traveled by car + /// + Car = Interop.RouteTransportMode.Car, + /// + /// Route is for a pedestrian + /// + Pedestrian = Interop.RouteTransportMode.Pedestrian, + /// + /// Route is for a cyclist + /// + Bicycle = Interop.RouteTransportMode.Bicycle, + /// + /// Route is to be traveled using public transport + /// + Publictransit = Interop.RouteTransportMode.PublicTransit, + /// + /// Route is for a truck + /// + Truck = Interop.RouteTransportMode.Truck, + } +} diff --git a/src/Tizen.Maps/Tizen.Maps/TurnInstruction.cs b/src/Tizen.Maps/Tizen.Maps/TurnInstruction.cs new file mode 100755 index 0000000..0cb2761 --- /dev/null +++ b/src/Tizen.Maps/Tizen.Maps/TurnInstruction.cs @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +namespace Tizen.Maps +{ + /// + /// Turn Instruction type for route maneuver + /// + public enum TurnInstruction + { + /// + /// Unknown Instruction + /// + None = Interop.RouteTurnType.None, + /// + /// Instruction to move straight + /// + Straight = Interop.RouteTurnType.Straight, + /// + /// Instruction to bear right + /// + BearRight = Interop.RouteTurnType.BearRight, + /// + /// Instruction to turn slightly to the right + /// + LightRight = Interop.RouteTurnType.LightRight, + /// + /// Instruction to turn right + /// + Right = Interop.RouteTurnType.Right, + /// + /// Instruction to turn hard to the right + /// + HardRight = Interop.RouteTurnType.HardRight, + /// + /// Instruction to u-turn to the right + /// + UturnRight = Interop.RouteTurnType.UturnRight, + /// + /// Instruction to u-turn to the left + /// + UturnLeft = Interop.RouteTurnType.UturnLeft, + /// + /// Instruction to turn hard to the left + /// + HardLeft = Interop.RouteTurnType.HardLeft, + /// + /// Instruction to turn left + /// + Left = Interop.RouteTurnType.Left, + /// + /// Instruction to turn slightly to the left + /// + LightLeft = Interop.RouteTurnType.LightLeft, + /// + /// Instruction to bear left + /// + BearLeft = Interop.RouteTurnType.BearLeft, + /// + /// Instruction to take right fork + /// + RightFork = Interop.RouteTurnType.RightFork, + /// + /// Instruction to take left fork + /// + LeftFork = Interop.RouteTurnType.LeftFork, + /// + /// Instruction to take straight fork + /// + StraightFork = Interop.RouteTurnType.StraightFork, + } +} -- 2.7.4