Loading...
Searching...
No Matches
LocationManagerExample.java
Go to the documentation of this file.
1package com.navigine.examples;
2
3import com.navigine.idl.java.*;
4
10 private NavigineSdk sdk;
11 private LocationManager locationManager;
12 private Location currentLocation;
13 private LocationListener locationListener;
14
16 initializeSdk();
17 setupLocationListener();
18 }
19
23 private void initializeSdk() {
24 try {
25 // [java_NavigineSdk_getInstance]
26 // Get SDK instance
28 // [java_NavigineSdk_getInstance]
29
30 // [java_NavigineSdk_setUserHash]
31 // Set user hash
32 sdk.setUserHash("USER-HASH-HERE");
33 // [java_NavigineSdk_setUserHash]
34
35 // [java_NavigineSdk_setServer]
36 // Set server URL (optional)
37 sdk.setServer("https://custom.navigine.com");
38 // [java_NavigineSdk_setServer]
39
40 // [java_NavigineSdk_getLocationManager]
41 // Get LocationManager for working with locations
42 locationManager = sdk.getLocationManager();
43 // [java_NavigineSdk_getLocationManager]
44
45 if (locationManager != null) {
46 System.out.println("LocationManager successfully initialized");
47 }
48 } catch (Exception e) {
49 System.err.println("Error initializing SDK: " + e.getMessage());
50 }
51 }
52
56 private void setupLocationListener() {
57 locationListener = new LocationListener() {
58 @Override
59 // [java_LocationListener_onLocationLoaded]
60 public void onLocationLoaded(Location location) {
61 System.out.println("Location loaded successfully");
62 currentLocation = location;
63 if (location != null) {
65 }
66 }
67 // [java_LocationListener_onLocationLoaded]
68
69 @Override
70 // [java_LocationListener_onLocationUploaded]
71 public void onLocationUploaded(int locationId) {
72 System.out.println("Location uploaded: " + locationId);
73 }
74 // [java_LocationListener_onLocationUploaded]
75
76 @Override
77 // [java_LocationListener_onLocationFailed]
78 public void onLocationFailed(int locationId, Error error) {
79 System.err.println("Failed to load location " + locationId + ": " + error.getMessage());
80 }
81 // [java_LocationListener_onLocationFailed]
82 };
83 }
84
89 if (locationManager == null) {
90 System.err.println("LocationManager not initialized");
91 return;
92 }
93
94 // [java_LocationManager_addLocationListener]
95 // Add location listener
96 locationManager.addLocationListener(locationListener);
97 // [java_LocationManager_addLocationListener]
98
99 // [java_LocationManager_setLocationId]
100 // Set location ID to load
101 locationManager.setLocationId(12345);
102 // [java_LocationManager_setLocationId]
103
104 // [java_LocationManager_getLocationId]
105 // Get current location ID
106 int currentLocationId = locationManager.getLocationId();
107 System.out.println("Current location ID: " + currentLocationId);
108 // [java_LocationManager_getLocationId]
109
110 // [java_LocationManager_setLocationUpdateInterval]
111 // Set location update interval (in seconds)
112 locationManager.setLocationUpdateInterval(600); // 10 minutes
113 // [java_LocationManager_setLocationUpdateInterval]
114
115 // [java_LocationManager_commitChanges]
116 // Commit changes
117 locationManager.commitChanges();
118 // [java_LocationManager_commitChanges]
119
120 // [java_LocationManager_revertChanges]
121 // Revert changes (if needed)
122 // locationManager.revertChanges();
123 // [java_LocationManager_revertChanges]
124 }
125
129 public void demonstrateLocationUsage(Location location) {
130 if (location == null) {
131 System.err.println("Location is null");
132 return;
133 }
134
135 // [java_Location_getId]
136 // Get location ID
137 int locationId = location.getId();
138 System.out.println("Location ID: " + locationId);
139 // [java_Location_getId]
140
141 // [java_Location_getVersion]
142 // Get location version
143 int version = location.getVersion();
144 System.out.println("Location version: " + version);
145 // [java_Location_getVersion]
146
147 // [java_Location_getName]
148 // Get location name
149 String name = location.getName();
150 System.out.println("Location name: " + name);
151 // [java_Location_getName]
152
153 // [java_Location_getDescript]
154 // Get location description
155 String description = location.getDescript();
156 System.out.println("Location description: " + description);
157 // [java_Location_getDescript]
158
159 // [java_Location_getModified]
160 // Check if location is modified
161 boolean isModified = location.getModified();
162 System.out.println("Location modified: " + isModified);
163 // [java_Location_getModified]
164
165 // [java_Location_getGraphTags]
166 // Get available graph tags
167 java.util.ArrayList<String> graphTags = location.getGraphTags();
168 System.out.println("Available graph tags: " + graphTags);
169 // [java_Location_getGraphTags]
170
171 // [java_Location_getElevationGraph]
172 // Get elevation graph by tag
173 if (!graphTags.isEmpty()) {
174 ElevationGraph elevationGraph = location.getElevationGraph(graphTags.get(0));
175 if (elevationGraph != null) {
176 demonstrateElevationGraphUsage(elevationGraph);
177 }
178 }
179 // [java_Location_getElevationGraph]
180
181 // [java_Location_getCategories]
182 // Get all categories
183 java.util.ArrayList<Category> categories = location.getCategories();
184 System.out.println("Number of categories: " + categories.size());
185 // [java_Location_getCategories]
186
187 // [java_Location_getCategoryById]
188 // Get category by ID
189 if (!categories.isEmpty()) {
190 Category category = location.getCategoryById(categories.get(0).getId());
191 if (category != null) {
192 demonstrateCategoryUsage(category);
193 }
194 }
195 // [java_Location_getCategoryById]
196
197 // [java_Location_getSublocations]
198 // Get all sublocations
199 java.util.ArrayList<Sublocation> sublocations = location.getSublocations();
200 System.out.println("Number of sublocations: " + sublocations.size());
201 // [java_Location_getSublocations]
202
203 // [java_Location_getSublocationById]
204 // Get sublocation by ID
205 if (!sublocations.isEmpty()) {
206 Sublocation sublocation = location.getSublocationById(sublocations.get(0).getId());
207 if (sublocation != null) {
208 demonstrateSublocationUsage(sublocation);
209 }
210 }
211 // [java_Location_getSublocationById]
212 }
213
217 public void demonstrateCategoryUsage(Category category) {
218 if (category == null) {
219 System.err.println("Category is null");
220 return;
221 }
222
223 // [java_Category_getId]
224 // Get category ID
225 int categoryId = category.getId();
226 System.out.println("Category ID: " + categoryId);
227 // [java_Category_getId]
228
229 // [java_Category_getName]
230 // Get category name
231 String categoryName = category.getName();
232 System.out.println("Category name: " + categoryName);
233 // [java_Category_getName]
234
235 // [java_Category_getImageUrl]
236 // Get category image URL
237 String imageUrl = category.getImageUrl();
238 if (imageUrl != null) {
239 System.out.println("Category image URL: " + imageUrl);
240 }
241 // [java_Category_getImageUrl]
242 }
243
247 public void demonstrateSublocationUsage(Sublocation sublocation) {
248 if (sublocation == null) {
249 System.err.println("Sublocation is null");
250 return;
251 }
252
253 // [java_Sublocation_getId]
254 // Get sublocation ID
255 int sublocationId = sublocation.getId();
256 System.out.println("Sublocation ID: " + sublocationId);
257 // [java_Sublocation_getId]
258
259 // [java_Sublocation_getName]
260 // Get sublocation name
261 String sublocationName = sublocation.getName();
262 System.out.println("Sublocation name: " + sublocationName);
263 // [java_Sublocation_getName]
264
265 // [java_Sublocation_getDescript]
266 // Get sublocation description
267 String sublocationDescription = sublocation.getDescript();
268 System.out.println("Sublocation description: " + sublocationDescription);
269 // [java_Sublocation_getDescript]
270
271 // [java_Sublocation_getCategoryId]
272 // Get category ID
273 int categoryId = sublocation.getCategoryId();
274 System.out.println("Sublocation category ID: " + categoryId);
275 // [java_Sublocation_getCategoryId]
276
277 // [java_Sublocation_getLocation]
278 // Get location ID
279 int locationId = sublocation.getLocation();
280 System.out.println("Sublocation location ID: " + locationId);
281 // [java_Sublocation_getLocation]
282
283 // [java_Sublocation_getWidth]
284 // Get sublocation width in meters
285 double width = sublocation.getWidth();
286 System.out.println("Sublocation width: " + width + " meters");
287 // [java_Sublocation_getWidth]
288
289 // [java_Sublocation_getHeight]
290 // Get sublocation height in meters
291 double height = sublocation.getHeight();
292 System.out.println("Sublocation height: " + height + " meters");
293 // [java_Sublocation_getHeight]
294
295 // [java_Sublocation_getAltitude]
296 // Get sublocation altitude in meters
297 Double altitude = sublocation.getAltitude();
298 if (altitude != null) {
299 System.out.println("Sublocation altitude: " + altitude + " meters");
300 }
301 // [java_Sublocation_getAltitude]
302
303 // [java_Sublocation_getAzimuth]
304 // Get sublocation azimuth in degrees
305 double azimuth = sublocation.getAzimuth();
306 System.out.println("Sublocation azimuth: " + azimuth + " degrees");
307 // [java_Sublocation_getAzimuth]
308
309 // [java_Sublocation_getOriginPoint]
310 // Get sublocation origin point in WGS84 coordinates
311 GlobalPoint originPoint = sublocation.getOriginPoint();
312 System.out.println("Sublocation origin point: " + originPoint.getLat() + ", " + originPoint.getLon());
313 // [java_Sublocation_getOriginPoint]
314
315 // [java_Sublocation_getLevelId]
316 // Get sublocation level ID
317 String levelId = sublocation.getLevelId();
318 System.out.println("Sublocation level ID: " + levelId);
319 // [java_Sublocation_getLevelId]
320
321 // [java_Sublocation_getExternalId]
322 // Get sublocation external ID
323 String externalId = sublocation.getExternalId();
324 System.out.println("Sublocation external ID: " + externalId);
325 // [java_Sublocation_getExternalId]
326
327 // [java_Sublocation_getBuildingName]
328 // Get sublocation building name
329 String buildingName = sublocation.getBuildingName();
330 System.out.println("Sublocation building name: " + buildingName);
331 // [java_Sublocation_getBuildingName]
332
333 // [java_Sublocation_getReferencePoints]
334 // Get reference points
335 java.util.ArrayList<ReferencePoint> referencePoints = sublocation.getReferencePoints();
336 System.out.println("Number of reference points: " + referencePoints.size());
337 // [java_Sublocation_getReferencePoints]
338
339 // [java_Sublocation_getVenues]
340 // Get venues
341 java.util.ArrayList<Venue> venues = sublocation.getVenues();
342 System.out.println("Number of venues: " + venues.size());
343 // [java_Sublocation_getVenues]
344
345 // [java_Sublocation_getZones]
346 // Get zones
347 java.util.ArrayList<Zone> zones = sublocation.getZones();
348 System.out.println("Number of zones: " + zones.size());
349 // [java_Sublocation_getZones]
350
351 // [java_Sublocation_getBeacons]
352 // Get beacons
353 java.util.ArrayList<Beacon> beacons = sublocation.getBeacons();
354 System.out.println("Number of beacons: " + beacons.size());
355 // [java_Sublocation_getBeacons]
356
357 // [java_Sublocation_getWifis]
358 // Get WiFi access points
359 java.util.ArrayList<Wifi> wifis = sublocation.getWifis();
360 System.out.println("Number of WiFi access points: " + wifis.size());
361 // [java_Sublocation_getWifis]
362
363 // [java_Sublocation_getEddystones]
364 // Get Eddystone beacons
365 java.util.ArrayList<Eddystone> eddystones = sublocation.getEddystones();
366 System.out.println("Number of Eddystone beacons: " + eddystones.size());
367 // [java_Sublocation_getEddystones]
368
369 // [java_Sublocation_getGraph]
370 // Get graph
371 Graph graph = sublocation.getGraph();
372 if (graph != null) {
374 }
375 // [java_Sublocation_getGraph]
376
377 // [java_Sublocation_getGraph_withTag]
378 // Get graph by tag
379 Graph graphByTag = sublocation.getGraph("main");
380 if (graphByTag != null) {
381 System.out.println("Found graph with tag \"main\"");
382 demonstrateGraphUsage(graphByTag);
383 }
384 // [java_Sublocation_getGraph_withTag]
385
386 // [java_Sublocation_getVenueById]
387 // Get venue by ID
388 if (!venues.isEmpty()) {
389 Venue venueById = sublocation.getVenueById(venues.get(0).getId());
390 if (venueById != null) {
391 System.out.println("Found venue by ID: " + venueById.getId());
392 demonstrateVenueUsage(venueById);
393 }
394 }
395 // [java_Sublocation_getVenueById]
396
397 // [java_Sublocation_getZoneById]
398 // Get zone by ID
399 if (!zones.isEmpty()) {
400 Zone zoneById = sublocation.getZoneById(zones.get(0).getId());
401 if (zoneById != null) {
402 System.out.println("Found zone by ID: " + zoneById.getId());
403 demonstrateZoneUsage(zoneById);
404 }
405 }
406 // [java_Sublocation_getZoneById]
407
408 // [java_Sublocation_globalToLocal]
409 // Convert global coordinates to local coordinates
410 GlobalPoint globalPoint = new GlobalPoint(55.7558, 37.6176); // Moscow coordinates
411 LocationPoint localPoint = sublocation.globalToLocal(globalPoint);
412 System.out.println("Global point " + globalPoint.getLat() + ", " + globalPoint.getLon() +
413 " converted to local: " + localPoint.getX() + ", " + localPoint.getY());
414 // [java_Sublocation_globalToLocal]
415
416 // [java_Sublocation_localToGlobal]
417 // Convert local coordinates to global coordinates
418 LocationPoint localPoint2 = new LocationPoint(100.0, 200.0);
419 GlobalPoint globalPoint2 = sublocation.localToGlobal(localPoint2);
420 System.out.println("Local point " + localPoint2.getX() + ", " + localPoint2.getY() +
421 " converted to global: " + globalPoint2.getLat() + ", " + globalPoint2.getLon());
422 // [java_Sublocation_localToGlobal]
423
424 // [java_Sublocation_getImage]
425 // Get sublocation image
426 ImageWrapper image = sublocation.getImage(1024); // max texture size 1024
427 if (image != null) {
428 System.out.println("Sublocation image obtained with max texture size 1024");
429 }
430 // [java_Sublocation_getImage]
431 }
432
436 public void demonstrateVenueUsage(Venue venue) {
437 if (venue == null) {
438 System.err.println("Venue is null");
439 return;
440 }
441
442 // [java_Venue_getId]
443 // Get venue ID
444 int venueId = venue.getId();
445 System.out.println("Venue ID: " + venueId);
446 // [java_Venue_getId]
447
448 // [java_Venue_getLocationId]
449 // Get venue location ID
450 int locationId = venue.getLocationId();
451 System.out.println("Venue location ID: " + locationId);
452 // [java_Venue_getLocationId]
453
454 // [java_Venue_getSublocationId]
455 // Get venue sublocation ID
456 int sublocationId = venue.getSublocationId();
457 System.out.println("Venue sublocation ID: " + sublocationId);
458 // [java_Venue_getSublocationId]
459
460 // [java_Venue_getName]
461 // Get venue name
462 String venueName = venue.getName();
463 System.out.println("Venue name: " + venueName);
464 // [java_Venue_getName]
465
466 // [java_Venue_getPhone]
467 // Get venue phone
468 String phone = venue.getPhone();
469 System.out.println("Venue phone: " + phone);
470 // [java_Venue_getPhone]
471
472 // [java_Venue_getDescript]
473 // Get venue description
474 String venueDescription = venue.getDescript();
475 System.out.println("Venue description: " + venueDescription);
476 // [java_Venue_getDescript]
477
478 // [java_Venue_getAlias]
479 // Get venue alias
480 String alias = venue.getAlias();
481 System.out.println("Venue alias: " + alias);
482 // [java_Venue_getAlias]
483
484 // [java_Venue_getCategoryId]
485 // Get category ID
486 int categoryId = venue.getCategoryId();
487 System.out.println("Venue category ID: " + categoryId);
488 // [java_Venue_getCategoryId]
489
490 // [java_Venue_getImageUrl]
491 // Get venue image URL
492 String imageUrl = venue.getImageUrl();
493 if (imageUrl != null) {
494 System.out.println("Venue image URL: " + imageUrl);
495 }
496 // [java_Venue_getImageUrl]
497
498 // [java_Venue_getPoint]
499 // Get venue point
500 Point point = venue.getPoint();
501 if (point != null) {
503 }
504 // [java_Venue_getPoint]
505 }
506
510 public void demonstrateZoneUsage(Zone zone) {
511 if (zone == null) {
512 System.err.println("Zone is null");
513 return;
514 }
515
516 // [java_Zone_getId]
517 // Get zone ID
518 int zoneId = zone.getId();
519 System.out.println("Zone ID: " + zoneId);
520 // [java_Zone_getId]
521
522 // [java_Zone_getGuid]
523 Long zoneGuid = zone.getGuid();
524 if (zoneGuid != null) {
525 System.out.println("Zone GUID: " + zoneGuid);
526 }
527 // [java_Zone_getGuid]
528
529 // [java_Zone_getLocationId]
530 // Get zone location ID
531 int locationId = zone.getLocationId();
532 System.out.println("Zone location ID: " + locationId);
533 // [java_Zone_getLocationId]
534
535 // [java_Zone_getSublocationId]
536 // Get zone sublocation ID
537 int sublocationId = zone.getSublocationId();
538 System.out.println("Zone sublocation ID: " + sublocationId);
539 // [java_Zone_getSublocationId]
540
541 // [java_Zone_getName]
542 // Get zone name
543 String zoneName = zone.getName();
544 System.out.println("Zone name: " + zoneName);
545 // [java_Zone_getName]
546
547 // [java_Zone_getDescript]
548 // Get zone description
549 String zoneDescription = zone.getDescript();
550 System.out.println("Zone description: " + zoneDescription);
551 // [java_Zone_getDescript]
552
553 // [java_Zone_getCategoryId]
554 // Get category ID
555 int categoryId = zone.getCategoryId();
556 System.out.println("Zone category ID: " + categoryId);
557 // [java_Zone_getCategoryId]
558
559 // [java_Zone_getAlias]
560 // Get zone alias
561 String alias = zone.getAlias();
562 System.out.println("Zone alias: " + alias);
563 // [java_Zone_getAlias]
564
565 // [java_Zone_getColor]
566 // Get zone color
567 int color = zone.getColor();
568 System.out.println("Zone color: " + color);
569 // [java_Zone_getColor]
570
571 // [java_Zone_getPolygon]
572 // Get zone polygon
573 java.util.ArrayList<Point> polygon = zone.getPolygon();
574 System.out.println("Zone polygon points: " + polygon.size());
575 // [java_Zone_getPolygon]
576 }
577
581 public void demonstrateBeaconUsage(Beacon beacon) {
582 if (beacon == null) {
583 System.err.println("Beacon is null");
584 return;
585 }
586
587 // [java_Beacon_getPoint]
588 // Get beacon point
589 Point point = beacon.getPoint();
590 if (point != null) {
592 }
593 // [java_Beacon_getPoint]
594
595 // [java_Beacon_getLocationId]
596 // Get beacon location ID
597 int locationId = beacon.getLocationId();
598 System.out.println("Beacon location ID: " + locationId);
599 // [java_Beacon_getLocationId]
600
601 // [java_Beacon_getSublocationId]
602 // Get beacon sublocation ID
603 int sublocationId = beacon.getSublocationId();
604 System.out.println("Beacon sublocation ID: " + sublocationId);
605 // [java_Beacon_getSublocationId]
606
607 // [java_Beacon_getName]
608 // Get beacon name
609 String beaconName = beacon.getName();
610 System.out.println("Beacon name: " + beaconName);
611 // [java_Beacon_getName]
612
613 // [java_Beacon_getMajor]
614 // Get beacon major
615 int major = beacon.getMajor();
616 System.out.println("Beacon major: " + major);
617 // [java_Beacon_getMajor]
618
619 // [java_Beacon_getMinor]
620 // Get beacon minor
621 int minor = beacon.getMinor();
622 System.out.println("Beacon minor: " + minor);
623 // [java_Beacon_getMinor]
624
625 // [java_Beacon_getUuid]
626 // Get beacon UUID
627 String uuid = beacon.getUuid();
628 System.out.println("Beacon UUID: " + uuid);
629 // [java_Beacon_getUuid]
630
631 // [java_Beacon_getPower]
632 // Get beacon power
633 Integer power = beacon.getPower();
634 if (power != null) {
635 System.out.println("Beacon power: " + power);
636 }
637 // [java_Beacon_getPower]
638
639 // [java_Beacon_getStatus]
640 // Get beacon status
641 TransmitterStatus status = beacon.getStatus();
642 System.out.println("Beacon status: " + status);
643 // [java_Beacon_getStatus]
644 }
645
649 public void demonstrateWifiUsage(Wifi wifi) {
650 if (wifi == null) {
651 System.err.println("WiFi is null");
652 return;
653 }
654
655 // [java_Wifi_getPoint]
656 // Get WiFi point
657 Point point = wifi.getPoint();
658 if (point != null) {
660 }
661 // [java_Wifi_getPoint]
662
663 // [java_Wifi_getLocationId]
664 // Get WiFi location ID
665 int locationId = wifi.getLocationId();
666 System.out.println("WiFi location ID: " + locationId);
667 // [java_Wifi_getLocationId]
668
669 // [java_Wifi_getSublocationId]
670 // Get WiFi sublocation ID
671 int sublocationId = wifi.getSublocationId();
672 System.out.println("WiFi sublocation ID: " + sublocationId);
673 // [java_Wifi_getSublocationId]
674
675 // [java_Wifi_getName]
676 // Get WiFi name
677 String wifiName = wifi.getName();
678 System.out.println("WiFi name: " + wifiName);
679 // [java_Wifi_getName]
680
681 // [java_Wifi_getMac]
682 // Get WiFi MAC address
683 String mac = wifi.getMac();
684 System.out.println("WiFi MAC: " + mac);
685 // [java_Wifi_getMac]
686
687 // [java_Wifi_getStatus]
688 // Get WiFi status
689 TransmitterStatus status = wifi.getStatus();
690 System.out.println("WiFi status: " + status);
691 // [java_Wifi_getStatus]
692 }
693
697 public void demonstrateEddystoneUsage(Eddystone eddystone) {
698 if (eddystone == null) {
699 System.err.println("Eddystone is null");
700 return;
701 }
702
703 // [java_Eddystone_getPoint]
704 // Get Eddystone point
705 Point point = eddystone.getPoint();
706 if (point != null) {
708 }
709 // [java_Eddystone_getPoint]
710
711 // [java_Eddystone_getLocationId]
712 // Get Eddystone location ID
713 int locationId = eddystone.getLocationId();
714 System.out.println("Eddystone location ID: " + locationId);
715 // [java_Eddystone_getLocationId]
716
717 // [java_Eddystone_getSublocationId]
718 // Get Eddystone sublocation ID
719 int sublocationId = eddystone.getSublocationId();
720 System.out.println("Eddystone sublocation ID: " + sublocationId);
721 // [java_Eddystone_getSublocationId]
722
723 // [java_Eddystone_getName]
724 // Get Eddystone name
725 String eddystoneName = eddystone.getName();
726 System.out.println("Eddystone name: " + eddystoneName);
727 // [java_Eddystone_getName]
728
729 // [java_Eddystone_getNamespaceId]
730 // Get Eddystone namespace ID
731 String namespaceId = eddystone.getNamespaceId();
732 System.out.println("Eddystone namespace ID: " + namespaceId);
733 // [java_Eddystone_getNamespaceId]
734
735 // [java_Eddystone_getInstanceId]
736 // Get Eddystone instance ID
737 String instanceId = eddystone.getInstanceId();
738 System.out.println("Eddystone instance ID: " + instanceId);
739 // [java_Eddystone_getInstanceId]
740
741 // [java_Eddystone_getPower]
742 // Get Eddystone power
743 Integer power = eddystone.getPower();
744 if (power != null) {
745 System.out.println("Eddystone power: " + power);
746 }
747 // [java_Eddystone_getPower]
748
749 // [java_Eddystone_getStatus]
750 // Get Eddystone status
751 TransmitterStatus status = eddystone.getStatus();
752 System.out.println("Eddystone status: " + status);
753 // [java_Eddystone_getStatus]
754 }
755
759 public void demonstratePointUsage(Point point) {
760 if (point == null) {
761 System.err.println("Point is null");
762 return;
763 }
764
765 // [java_Point_getX]
766 // Get X coordinate
767 double x = point.getX();
768 System.out.println("Point X: " + x);
769 // [java_Point_getX]
770
771 // [java_Point_getY]
772 // Get Y coordinate
773 double y = point.getY();
774 System.out.println("Point Y: " + y);
775 // [java_Point_getY]
776 }
777
781 public void demonstrateGraphUsage(Graph graph) {
782 if (graph == null) {
783 System.err.println("Graph is null");
784 return;
785 }
786
787 // [java_Graph_getVertices]
788 // Get graph vertices
789 java.util.ArrayList<GraphVertex> vertices = graph.getVertices();
790 System.out.println("Number of graph vertices: " + vertices.size());
791 // [java_Graph_getVertices]
792
793 // [java_Graph_getEdges]
794 // Get graph edges
795 java.util.ArrayList<GraphEdge> edges = graph.getEdges();
796 System.out.println("Number of graph edges: " + edges.size());
797 // [java_Graph_getEdges]
798 }
799
804 if (vertex == null) {
805 System.err.println("GraphVertex is null");
806 return;
807 }
808
809 // [java_GraphVertex_getId]
810 // Get vertex ID
811 int vertexId = vertex.getId();
812 System.out.println("Vertex ID: " + vertexId);
813 // [java_GraphVertex_getId]
814
815 // [java_GraphVertex_getPoint]
816 // Get vertex point
817 Point point = vertex.getPoint();
818 if (point != null) {
820 }
821 // [java_GraphVertex_getPoint]
822
823 // [java_GraphVertex_getName]
824 // Get vertex name
825 String name = vertex.getName();
826 System.out.println("Vertex name: " + name);
827 // [java_GraphVertex_getName]
828
829 // [java_GraphVertex_getIsExternal]
830 // Get vertex external flag
831 boolean isExternal = vertex.getIsExternal();
832 System.out.println("Vertex is external: " + isExternal);
833 // [java_GraphVertex_getIsExternal]
834
835 // [java_GraphVertex_getIsElevation]
836 // Get vertex elevation flag
837 boolean isElevation = vertex.getIsElevation();
838 System.out.println("Vertex is elevation: " + isElevation);
839 // [java_GraphVertex_getIsElevation]
840 }
841
846 if (edge == null) {
847 System.err.println("GraphEdge is null");
848 return;
849 }
850
851 // [java_GraphEdge_getWeight]
852 // Get edge weight
853 float weight = edge.getWeight();
854 System.out.println("Edge weight: " + weight);
855 // [java_GraphEdge_getWeight]
856
857 // [java_GraphEdge_getDst]
858 // Get destination vertex ID
859 int dst = edge.getDst();
860 System.out.println("Edge destination ID: " + dst);
861 // [java_GraphEdge_getDst]
862
863 // [java_GraphEdge_getSrc]
864 // Get source vertex ID
865 int src = edge.getSrc();
866 System.out.println("Edge source ID: " + src);
867 // [java_GraphEdge_getSrc]
868
869 // [java_GraphEdge_getWeightCoef]
870 // Get edge weight coefficient
871 int weightCoef = edge.getWeightCoef();
872 System.out.println("Edge weight coefficient: " + weightCoef);
873 // [java_GraphEdge_getWeightCoef]
874 }
875
879 public void demonstrateElevationGraphUsage(ElevationGraph elevationGraph) {
880 if (elevationGraph == null) {
881 System.err.println("ElevationGraph is null");
882 return;
883 }
884
885 // [java_ElevationGraph_getEdges]
886 // Get elevation graph edges
887 java.util.ArrayList<GraphEdge> edges = elevationGraph.getEdges();
888 System.out.println("Number of elevation graph edges: " + edges.size());
889
890 // Demonstrate each edge
891 for (int i = 0; i < edges.size(); i++) {
892 GraphEdge edge = edges.get(i);
893 System.out.println("Elevation graph edge " + (i + 1) + ":");
895 }
896 // [java_ElevationGraph_getEdges]
897 }
898
903 // [java_TransmitterStatus_values]
904 // Get all transmitter status values
905 TransmitterStatus[] statuses = TransmitterStatus.values();
906 System.out.println("Available transmitter statuses:");
907 for (TransmitterStatus status : statuses) {
908 System.out.println(" - " + status);
909 }
910 // [java_TransmitterStatus_values]
911 }
912
916 public void cleanup() {
917 if (locationManager != null && locationListener != null) {
918 // [java_LocationManager_removeLocationListener]
919 // Remove location listener
920 locationManager.removeLocationListener(locationListener);
921 // [java_LocationManager_removeLocationListener]
922 }
923 }
924
928 public void runExample() {
929 System.out.println("=== LocationManager Example ===");
930
933
934 // Wait a bit for location to load
935 try {
936 Thread.sleep(2000);
937 } catch (InterruptedException e) {
938 Thread.currentThread().interrupt();
939 }
940
941 cleanup();
942 System.out.println("=== Example completed ===");
943 }
944
948 public static void main(String[] args) {
950 example.runExample();
951 }
952}