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_getLocationId]
523 // Get zone location ID
524 int locationId = zone.getLocationId();
525 System.out.println("Zone location ID: " + locationId);
526 // [java_Zone_getLocationId]
527
528 // [java_Zone_getSublocationId]
529 // Get zone sublocation ID
530 int sublocationId = zone.getSublocationId();
531 System.out.println("Zone sublocation ID: " + sublocationId);
532 // [java_Zone_getSublocationId]
533
534 // [java_Zone_getName]
535 // Get zone name
536 String zoneName = zone.getName();
537 System.out.println("Zone name: " + zoneName);
538 // [java_Zone_getName]
539
540 // [java_Zone_getDescript]
541 // Get zone description
542 String zoneDescription = zone.getDescript();
543 System.out.println("Zone description: " + zoneDescription);
544 // [java_Zone_getDescript]
545
546 // [java_Zone_getCategoryId]
547 // Get category ID
548 int categoryId = zone.getCategoryId();
549 System.out.println("Zone category ID: " + categoryId);
550 // [java_Zone_getCategoryId]
551
552 // [java_Zone_getAlias]
553 // Get zone alias
554 String alias = zone.getAlias();
555 System.out.println("Zone alias: " + alias);
556 // [java_Zone_getAlias]
557
558 // [java_Zone_getColor]
559 // Get zone color
560 String color = zone.getColor();
561 System.out.println("Zone color: " + color);
562 // [java_Zone_getColor]
563
564 // [java_Zone_getPolygon]
565 // Get zone polygon
566 java.util.ArrayList<Point> polygon = zone.getPolygon();
567 System.out.println("Zone polygon points: " + polygon.size());
568 // [java_Zone_getPolygon]
569 }
570
574 public void demonstrateBeaconUsage(Beacon beacon) {
575 if (beacon == null) {
576 System.err.println("Beacon is null");
577 return;
578 }
579
580 // [java_Beacon_getPoint]
581 // Get beacon point
582 Point point = beacon.getPoint();
583 if (point != null) {
585 }
586 // [java_Beacon_getPoint]
587
588 // [java_Beacon_getLocationId]
589 // Get beacon location ID
590 int locationId = beacon.getLocationId();
591 System.out.println("Beacon location ID: " + locationId);
592 // [java_Beacon_getLocationId]
593
594 // [java_Beacon_getSublocationId]
595 // Get beacon sublocation ID
596 int sublocationId = beacon.getSublocationId();
597 System.out.println("Beacon sublocation ID: " + sublocationId);
598 // [java_Beacon_getSublocationId]
599
600 // [java_Beacon_getName]
601 // Get beacon name
602 String beaconName = beacon.getName();
603 System.out.println("Beacon name: " + beaconName);
604 // [java_Beacon_getName]
605
606 // [java_Beacon_getMajor]
607 // Get beacon major
608 int major = beacon.getMajor();
609 System.out.println("Beacon major: " + major);
610 // [java_Beacon_getMajor]
611
612 // [java_Beacon_getMinor]
613 // Get beacon minor
614 int minor = beacon.getMinor();
615 System.out.println("Beacon minor: " + minor);
616 // [java_Beacon_getMinor]
617
618 // [java_Beacon_getUuid]
619 // Get beacon UUID
620 String uuid = beacon.getUuid();
621 System.out.println("Beacon UUID: " + uuid);
622 // [java_Beacon_getUuid]
623
624 // [java_Beacon_getPower]
625 // Get beacon power
626 Integer power = beacon.getPower();
627 if (power != null) {
628 System.out.println("Beacon power: " + power);
629 }
630 // [java_Beacon_getPower]
631
632 // [java_Beacon_getStatus]
633 // Get beacon status
634 TransmitterStatus status = beacon.getStatus();
635 System.out.println("Beacon status: " + status);
636 // [java_Beacon_getStatus]
637 }
638
642 public void demonstrateWifiUsage(Wifi wifi) {
643 if (wifi == null) {
644 System.err.println("WiFi is null");
645 return;
646 }
647
648 // [java_Wifi_getPoint]
649 // Get WiFi point
650 Point point = wifi.getPoint();
651 if (point != null) {
653 }
654 // [java_Wifi_getPoint]
655
656 // [java_Wifi_getLocationId]
657 // Get WiFi location ID
658 int locationId = wifi.getLocationId();
659 System.out.println("WiFi location ID: " + locationId);
660 // [java_Wifi_getLocationId]
661
662 // [java_Wifi_getSublocationId]
663 // Get WiFi sublocation ID
664 int sublocationId = wifi.getSublocationId();
665 System.out.println("WiFi sublocation ID: " + sublocationId);
666 // [java_Wifi_getSublocationId]
667
668 // [java_Wifi_getName]
669 // Get WiFi name
670 String wifiName = wifi.getName();
671 System.out.println("WiFi name: " + wifiName);
672 // [java_Wifi_getName]
673
674 // [java_Wifi_getMac]
675 // Get WiFi MAC address
676 String mac = wifi.getMac();
677 System.out.println("WiFi MAC: " + mac);
678 // [java_Wifi_getMac]
679
680 // [java_Wifi_getStatus]
681 // Get WiFi status
682 TransmitterStatus status = wifi.getStatus();
683 System.out.println("WiFi status: " + status);
684 // [java_Wifi_getStatus]
685 }
686
690 public void demonstrateEddystoneUsage(Eddystone eddystone) {
691 if (eddystone == null) {
692 System.err.println("Eddystone is null");
693 return;
694 }
695
696 // [java_Eddystone_getPoint]
697 // Get Eddystone point
698 Point point = eddystone.getPoint();
699 if (point != null) {
701 }
702 // [java_Eddystone_getPoint]
703
704 // [java_Eddystone_getLocationId]
705 // Get Eddystone location ID
706 int locationId = eddystone.getLocationId();
707 System.out.println("Eddystone location ID: " + locationId);
708 // [java_Eddystone_getLocationId]
709
710 // [java_Eddystone_getSublocationId]
711 // Get Eddystone sublocation ID
712 int sublocationId = eddystone.getSublocationId();
713 System.out.println("Eddystone sublocation ID: " + sublocationId);
714 // [java_Eddystone_getSublocationId]
715
716 // [java_Eddystone_getName]
717 // Get Eddystone name
718 String eddystoneName = eddystone.getName();
719 System.out.println("Eddystone name: " + eddystoneName);
720 // [java_Eddystone_getName]
721
722 // [java_Eddystone_getNamespaceId]
723 // Get Eddystone namespace ID
724 String namespaceId = eddystone.getNamespaceId();
725 System.out.println("Eddystone namespace ID: " + namespaceId);
726 // [java_Eddystone_getNamespaceId]
727
728 // [java_Eddystone_getInstanceId]
729 // Get Eddystone instance ID
730 String instanceId = eddystone.getInstanceId();
731 System.out.println("Eddystone instance ID: " + instanceId);
732 // [java_Eddystone_getInstanceId]
733
734 // [java_Eddystone_getPower]
735 // Get Eddystone power
736 Integer power = eddystone.getPower();
737 if (power != null) {
738 System.out.println("Eddystone power: " + power);
739 }
740 // [java_Eddystone_getPower]
741
742 // [java_Eddystone_getStatus]
743 // Get Eddystone status
744 TransmitterStatus status = eddystone.getStatus();
745 System.out.println("Eddystone status: " + status);
746 // [java_Eddystone_getStatus]
747 }
748
752 public void demonstratePointUsage(Point point) {
753 if (point == null) {
754 System.err.println("Point is null");
755 return;
756 }
757
758 // [java_Point_getX]
759 // Get X coordinate
760 double x = point.getX();
761 System.out.println("Point X: " + x);
762 // [java_Point_getX]
763
764 // [java_Point_getY]
765 // Get Y coordinate
766 double y = point.getY();
767 System.out.println("Point Y: " + y);
768 // [java_Point_getY]
769 }
770
774 public void demonstrateGraphUsage(Graph graph) {
775 if (graph == null) {
776 System.err.println("Graph is null");
777 return;
778 }
779
780 // [java_Graph_getVertices]
781 // Get graph vertices
782 java.util.ArrayList<GraphVertex> vertices = graph.getVertices();
783 System.out.println("Number of graph vertices: " + vertices.size());
784 // [java_Graph_getVertices]
785
786 // [java_Graph_getEdges]
787 // Get graph edges
788 java.util.ArrayList<GraphEdge> edges = graph.getEdges();
789 System.out.println("Number of graph edges: " + edges.size());
790 // [java_Graph_getEdges]
791 }
792
797 if (vertex == null) {
798 System.err.println("GraphVertex is null");
799 return;
800 }
801
802 // [java_GraphVertex_getId]
803 // Get vertex ID
804 int vertexId = vertex.getId();
805 System.out.println("Vertex ID: " + vertexId);
806 // [java_GraphVertex_getId]
807
808 // [java_GraphVertex_getPoint]
809 // Get vertex point
810 Point point = vertex.getPoint();
811 if (point != null) {
813 }
814 // [java_GraphVertex_getPoint]
815
816 // [java_GraphVertex_getName]
817 // Get vertex name
818 String name = vertex.getName();
819 System.out.println("Vertex name: " + name);
820 // [java_GraphVertex_getName]
821
822 // [java_GraphVertex_getIsExternal]
823 // Get vertex external flag
824 boolean isExternal = vertex.getIsExternal();
825 System.out.println("Vertex is external: " + isExternal);
826 // [java_GraphVertex_getIsExternal]
827
828 // [java_GraphVertex_getIsElevation]
829 // Get vertex elevation flag
830 boolean isElevation = vertex.getIsElevation();
831 System.out.println("Vertex is elevation: " + isElevation);
832 // [java_GraphVertex_getIsElevation]
833 }
834
839 if (edge == null) {
840 System.err.println("GraphEdge is null");
841 return;
842 }
843
844 // [java_GraphEdge_getWeight]
845 // Get edge weight
846 float weight = edge.getWeight();
847 System.out.println("Edge weight: " + weight);
848 // [java_GraphEdge_getWeight]
849
850 // [java_GraphEdge_getDst]
851 // Get destination vertex ID
852 int dst = edge.getDst();
853 System.out.println("Edge destination ID: " + dst);
854 // [java_GraphEdge_getDst]
855
856 // [java_GraphEdge_getSrc]
857 // Get source vertex ID
858 int src = edge.getSrc();
859 System.out.println("Edge source ID: " + src);
860 // [java_GraphEdge_getSrc]
861
862 // [java_GraphEdge_getWeightCoef]
863 // Get edge weight coefficient
864 int weightCoef = edge.getWeightCoef();
865 System.out.println("Edge weight coefficient: " + weightCoef);
866 // [java_GraphEdge_getWeightCoef]
867 }
868
872 public void demonstrateElevationGraphUsage(ElevationGraph elevationGraph) {
873 if (elevationGraph == null) {
874 System.err.println("ElevationGraph is null");
875 return;
876 }
877
878 // [java_ElevationGraph_getEdges]
879 // Get elevation graph edges
880 java.util.ArrayList<GraphEdge> edges = elevationGraph.getEdges();
881 System.out.println("Number of elevation graph edges: " + edges.size());
882
883 // Demonstrate each edge
884 for (int i = 0; i < edges.size(); i++) {
885 GraphEdge edge = edges.get(i);
886 System.out.println("Elevation graph edge " + (i + 1) + ":");
888 }
889 // [java_ElevationGraph_getEdges]
890 }
891
896 // [java_TransmitterStatus_values]
897 // Get all transmitter status values
898 TransmitterStatus[] statuses = TransmitterStatus.values();
899 System.out.println("Available transmitter statuses:");
900 for (TransmitterStatus status : statuses) {
901 System.out.println(" - " + status);
902 }
903 // [java_TransmitterStatus_values]
904 }
905
909 public void cleanup() {
910 if (locationManager != null && locationListener != null) {
911 // [java_LocationManager_removeLocationListener]
912 // Remove location listener
913 locationManager.removeLocationListener(locationListener);
914 // [java_LocationManager_removeLocationListener]
915 }
916 }
917
921 public void runExample() {
922 System.out.println("=== LocationManager Example ===");
923
926
927 // Wait a bit for location to load
928 try {
929 Thread.sleep(2000);
930 } catch (InterruptedException e) {
931 Thread.currentThread().interrupt();
932 }
933
934 cleanup();
935 System.out.println("=== Example completed ===");
936 }
937
941 public static void main(String[] args) {
943 example.runExample();
944 }
945}