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
27 sdk = NavigineSdk.getInstance();
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_getReferencePoints]
328 // Get reference points
329 java.util.ArrayList<ReferencePoint> referencePoints = sublocation.getReferencePoints();
330 System.out.println("Number of reference points: " + referencePoints.size());
331 // [java_Sublocation_getReferencePoints]
332
333 // [java_Sublocation_getVenues]
334 // Get venues
335 java.util.ArrayList<Venue> venues = sublocation.getVenues();
336 System.out.println("Number of venues: " + venues.size());
337 // [java_Sublocation_getVenues]
338
339 // [java_Sublocation_getZones]
340 // Get zones
341 java.util.ArrayList<Zone> zones = sublocation.getZones();
342 System.out.println("Number of zones: " + zones.size());
343 // [java_Sublocation_getZones]
344
345 // [java_Sublocation_getBeacons]
346 // Get beacons
347 java.util.ArrayList<Beacon> beacons = sublocation.getBeacons();
348 System.out.println("Number of beacons: " + beacons.size());
349 // [java_Sublocation_getBeacons]
350
351 // [java_Sublocation_getWifis]
352 // Get WiFi access points
353 java.util.ArrayList<Wifi> wifis = sublocation.getWifis();
354 System.out.println("Number of WiFi access points: " + wifis.size());
355 // [java_Sublocation_getWifis]
356
357 // [java_Sublocation_getEddystones]
358 // Get Eddystone beacons
359 java.util.ArrayList<Eddystone> eddystones = sublocation.getEddystones();
360 System.out.println("Number of Eddystone beacons: " + eddystones.size());
361 // [java_Sublocation_getEddystones]
362
363 // [java_Sublocation_getGraph]
364 // Get graph
365 Graph graph = sublocation.getGraph();
366 if (graph != null) {
368 }
369 // [java_Sublocation_getGraph]
370
371 // [java_Sublocation_getGraph_withTag]
372 // Get graph by tag
373 Graph graphByTag = sublocation.getGraph("main");
374 if (graphByTag != null) {
375 System.out.println("Found graph with tag \"main\"");
376 demonstrateGraphUsage(graphByTag);
377 }
378 // [java_Sublocation_getGraph_withTag]
379
380 // [java_Sublocation_getVenueById]
381 // Get venue by ID
382 if (!venues.isEmpty()) {
383 Venue venueById = sublocation.getVenueById(venues.get(0).getId());
384 if (venueById != null) {
385 System.out.println("Found venue by ID: " + venueById.getId());
386 demonstrateVenueUsage(venueById);
387 }
388 }
389 // [java_Sublocation_getVenueById]
390
391 // [java_Sublocation_getZoneById]
392 // Get zone by ID
393 if (!zones.isEmpty()) {
394 Zone zoneById = sublocation.getZoneById(zones.get(0).getId());
395 if (zoneById != null) {
396 System.out.println("Found zone by ID: " + zoneById.getId());
397 demonstrateZoneUsage(zoneById);
398 }
399 }
400 // [java_Sublocation_getZoneById]
401
402 // [java_Sublocation_globalToLocal]
403 // Convert global coordinates to local coordinates
404 GlobalPoint globalPoint = new GlobalPoint(55.7558, 37.6176); // Moscow coordinates
405 LocationPoint localPoint = sublocation.globalToLocal(globalPoint);
406 System.out.println("Global point " + globalPoint.getLat() + ", " + globalPoint.getLon() +
407 " converted to local: " + localPoint.getX() + ", " + localPoint.getY());
408 // [java_Sublocation_globalToLocal]
409
410 // [java_Sublocation_localToGlobal]
411 // Convert local coordinates to global coordinates
412 LocationPoint localPoint2 = new LocationPoint(100.0, 200.0);
413 GlobalPoint globalPoint2 = sublocation.localToGlobal(localPoint2);
414 System.out.println("Local point " + localPoint2.getX() + ", " + localPoint2.getY() +
415 " converted to global: " + globalPoint2.getLat() + ", " + globalPoint2.getLon());
416 // [java_Sublocation_localToGlobal]
417
418 // [java_Sublocation_getImage]
419 // Get sublocation image
420 ImageWrapper image = sublocation.getImage(1024); // max texture size 1024
421 if (image != null) {
422 System.out.println("Sublocation image obtained with max texture size 1024");
423 }
424 // [java_Sublocation_getImage]
425 }
426
430 public void demonstrateVenueUsage(Venue venue) {
431 if (venue == null) {
432 System.err.println("Venue is null");
433 return;
434 }
435
436 // [java_Venue_getId]
437 // Get venue ID
438 int venueId = venue.getId();
439 System.out.println("Venue ID: " + venueId);
440 // [java_Venue_getId]
441
442 // [java_Venue_getLocationId]
443 // Get venue location ID
444 int locationId = venue.getLocationId();
445 System.out.println("Venue location ID: " + locationId);
446 // [java_Venue_getLocationId]
447
448 // [java_Venue_getSublocationId]
449 // Get venue sublocation ID
450 int sublocationId = venue.getSublocationId();
451 System.out.println("Venue sublocation ID: " + sublocationId);
452 // [java_Venue_getSublocationId]
453
454 // [java_Venue_getName]
455 // Get venue name
456 String venueName = venue.getName();
457 System.out.println("Venue name: " + venueName);
458 // [java_Venue_getName]
459
460 // [java_Venue_getPhone]
461 // Get venue phone
462 String phone = venue.getPhone();
463 System.out.println("Venue phone: " + phone);
464 // [java_Venue_getPhone]
465
466 // [java_Venue_getDescript]
467 // Get venue description
468 String venueDescription = venue.getDescript();
469 System.out.println("Venue description: " + venueDescription);
470 // [java_Venue_getDescript]
471
472 // [java_Venue_getAlias]
473 // Get venue alias
474 String alias = venue.getAlias();
475 System.out.println("Venue alias: " + alias);
476 // [java_Venue_getAlias]
477
478 // [java_Venue_getCategoryId]
479 // Get category ID
480 int categoryId = venue.getCategoryId();
481 System.out.println("Venue category ID: " + categoryId);
482 // [java_Venue_getCategoryId]
483
484 // [java_Venue_getImageUrl]
485 // Get venue image URL
486 String imageUrl = venue.getImageUrl();
487 if (imageUrl != null) {
488 System.out.println("Venue image URL: " + imageUrl);
489 }
490 // [java_Venue_getImageUrl]
491
492 // [java_Venue_getPoint]
493 // Get venue point
494 Point point = venue.getPoint();
495 if (point != null) {
497 }
498 // [java_Venue_getPoint]
499 }
500
504 public void demonstrateZoneUsage(Zone zone) {
505 if (zone == null) {
506 System.err.println("Zone is null");
507 return;
508 }
509
510 // [java_Zone_getId]
511 // Get zone ID
512 int zoneId = zone.getId();
513 System.out.println("Zone ID: " + zoneId);
514 // [java_Zone_getId]
515
516 // [java_Zone_getLocationId]
517 // Get zone location ID
518 int locationId = zone.getLocationId();
519 System.out.println("Zone location ID: " + locationId);
520 // [java_Zone_getLocationId]
521
522 // [java_Zone_getSublocationId]
523 // Get zone sublocation ID
524 int sublocationId = zone.getSublocationId();
525 System.out.println("Zone sublocation ID: " + sublocationId);
526 // [java_Zone_getSublocationId]
527
528 // [java_Zone_getName]
529 // Get zone name
530 String zoneName = zone.getName();
531 System.out.println("Zone name: " + zoneName);
532 // [java_Zone_getName]
533
534 // [java_Zone_getDescript]
535 // Get zone description
536 String zoneDescription = zone.getDescript();
537 System.out.println("Zone description: " + zoneDescription);
538 // [java_Zone_getDescript]
539
540 // [java_Zone_getCategoryId]
541 // Get category ID
542 int categoryId = zone.getCategoryId();
543 System.out.println("Zone category ID: " + categoryId);
544 // [java_Zone_getCategoryId]
545
546 // [java_Zone_getAlias]
547 // Get zone alias
548 String alias = zone.getAlias();
549 System.out.println("Zone alias: " + alias);
550 // [java_Zone_getAlias]
551
552 // [java_Zone_getColor]
553 // Get zone color
554 String color = zone.getColor();
555 System.out.println("Zone color: " + color);
556 // [java_Zone_getColor]
557
558 // [java_Zone_getPolygon]
559 // Get zone polygon
560 java.util.ArrayList<Point> polygon = zone.getPolygon();
561 System.out.println("Zone polygon points: " + polygon.size());
562 // [java_Zone_getPolygon]
563 }
564
568 public void demonstrateBeaconUsage(Beacon beacon) {
569 if (beacon == null) {
570 System.err.println("Beacon is null");
571 return;
572 }
573
574 // [java_Beacon_getPoint]
575 // Get beacon point
576 Point point = beacon.getPoint();
577 if (point != null) {
579 }
580 // [java_Beacon_getPoint]
581
582 // [java_Beacon_getLocationId]
583 // Get beacon location ID
584 int locationId = beacon.getLocationId();
585 System.out.println("Beacon location ID: " + locationId);
586 // [java_Beacon_getLocationId]
587
588 // [java_Beacon_getSublocationId]
589 // Get beacon sublocation ID
590 int sublocationId = beacon.getSublocationId();
591 System.out.println("Beacon sublocation ID: " + sublocationId);
592 // [java_Beacon_getSublocationId]
593
594 // [java_Beacon_getName]
595 // Get beacon name
596 String beaconName = beacon.getName();
597 System.out.println("Beacon name: " + beaconName);
598 // [java_Beacon_getName]
599
600 // [java_Beacon_getMajor]
601 // Get beacon major
602 int major = beacon.getMajor();
603 System.out.println("Beacon major: " + major);
604 // [java_Beacon_getMajor]
605
606 // [java_Beacon_getMinor]
607 // Get beacon minor
608 int minor = beacon.getMinor();
609 System.out.println("Beacon minor: " + minor);
610 // [java_Beacon_getMinor]
611
612 // [java_Beacon_getUuid]
613 // Get beacon UUID
614 String uuid = beacon.getUuid();
615 System.out.println("Beacon UUID: " + uuid);
616 // [java_Beacon_getUuid]
617
618 // [java_Beacon_getPower]
619 // Get beacon power
620 Integer power = beacon.getPower();
621 if (power != null) {
622 System.out.println("Beacon power: " + power);
623 }
624 // [java_Beacon_getPower]
625
626 // [java_Beacon_getStatus]
627 // Get beacon status
628 TransmitterStatus status = beacon.getStatus();
629 System.out.println("Beacon status: " + status);
630 // [java_Beacon_getStatus]
631 }
632
636 public void demonstrateWifiUsage(Wifi wifi) {
637 if (wifi == null) {
638 System.err.println("WiFi is null");
639 return;
640 }
641
642 // [java_Wifi_getPoint]
643 // Get WiFi point
644 Point point = wifi.getPoint();
645 if (point != null) {
647 }
648 // [java_Wifi_getPoint]
649
650 // [java_Wifi_getLocationId]
651 // Get WiFi location ID
652 int locationId = wifi.getLocationId();
653 System.out.println("WiFi location ID: " + locationId);
654 // [java_Wifi_getLocationId]
655
656 // [java_Wifi_getSublocationId]
657 // Get WiFi sublocation ID
658 int sublocationId = wifi.getSublocationId();
659 System.out.println("WiFi sublocation ID: " + sublocationId);
660 // [java_Wifi_getSublocationId]
661
662 // [java_Wifi_getName]
663 // Get WiFi name
664 String wifiName = wifi.getName();
665 System.out.println("WiFi name: " + wifiName);
666 // [java_Wifi_getName]
667
668 // [java_Wifi_getMac]
669 // Get WiFi MAC address
670 String mac = wifi.getMac();
671 System.out.println("WiFi MAC: " + mac);
672 // [java_Wifi_getMac]
673
674 // [java_Wifi_getStatus]
675 // Get WiFi status
676 TransmitterStatus status = wifi.getStatus();
677 System.out.println("WiFi status: " + status);
678 // [java_Wifi_getStatus]
679 }
680
684 public void demonstrateEddystoneUsage(Eddystone eddystone) {
685 if (eddystone == null) {
686 System.err.println("Eddystone is null");
687 return;
688 }
689
690 // [java_Eddystone_getPoint]
691 // Get Eddystone point
692 Point point = eddystone.getPoint();
693 if (point != null) {
695 }
696 // [java_Eddystone_getPoint]
697
698 // [java_Eddystone_getLocationId]
699 // Get Eddystone location ID
700 int locationId = eddystone.getLocationId();
701 System.out.println("Eddystone location ID: " + locationId);
702 // [java_Eddystone_getLocationId]
703
704 // [java_Eddystone_getSublocationId]
705 // Get Eddystone sublocation ID
706 int sublocationId = eddystone.getSublocationId();
707 System.out.println("Eddystone sublocation ID: " + sublocationId);
708 // [java_Eddystone_getSublocationId]
709
710 // [java_Eddystone_getName]
711 // Get Eddystone name
712 String eddystoneName = eddystone.getName();
713 System.out.println("Eddystone name: " + eddystoneName);
714 // [java_Eddystone_getName]
715
716 // [java_Eddystone_getNamespaceId]
717 // Get Eddystone namespace ID
718 String namespaceId = eddystone.getNamespaceId();
719 System.out.println("Eddystone namespace ID: " + namespaceId);
720 // [java_Eddystone_getNamespaceId]
721
722 // [java_Eddystone_getInstanceId]
723 // Get Eddystone instance ID
724 String instanceId = eddystone.getInstanceId();
725 System.out.println("Eddystone instance ID: " + instanceId);
726 // [java_Eddystone_getInstanceId]
727
728 // [java_Eddystone_getPower]
729 // Get Eddystone power
730 Integer power = eddystone.getPower();
731 if (power != null) {
732 System.out.println("Eddystone power: " + power);
733 }
734 // [java_Eddystone_getPower]
735
736 // [java_Eddystone_getStatus]
737 // Get Eddystone status
738 TransmitterStatus status = eddystone.getStatus();
739 System.out.println("Eddystone status: " + status);
740 // [java_Eddystone_getStatus]
741 }
742
746 public void demonstratePointUsage(Point point) {
747 if (point == null) {
748 System.err.println("Point is null");
749 return;
750 }
751
752 // [java_Point_getX]
753 // Get X coordinate
754 double x = point.getX();
755 System.out.println("Point X: " + x);
756 // [java_Point_getX]
757
758 // [java_Point_getY]
759 // Get Y coordinate
760 double y = point.getY();
761 System.out.println("Point Y: " + y);
762 // [java_Point_getY]
763 }
764
768 public void demonstrateGraphUsage(Graph graph) {
769 if (graph == null) {
770 System.err.println("Graph is null");
771 return;
772 }
773
774 // [java_Graph_getVertices]
775 // Get graph vertices
776 java.util.ArrayList<GraphVertex> vertices = graph.getVertices();
777 System.out.println("Number of graph vertices: " + vertices.size());
778 // [java_Graph_getVertices]
779
780 // [java_Graph_getEdges]
781 // Get graph edges
782 java.util.ArrayList<GraphEdge> edges = graph.getEdges();
783 System.out.println("Number of graph edges: " + edges.size());
784 // [java_Graph_getEdges]
785 }
786
790 public void demonstrateGraphVertexUsage(GraphVertex vertex) {
791 if (vertex == null) {
792 System.err.println("GraphVertex is null");
793 return;
794 }
795
796 // [java_GraphVertex_getId]
797 // Get vertex ID
798 int vertexId = vertex.getId();
799 System.out.println("Vertex ID: " + vertexId);
800 // [java_GraphVertex_getId]
801
802 // [java_GraphVertex_getPoint]
803 // Get vertex point
804 Point point = vertex.getPoint();
805 if (point != null) {
807 }
808 // [java_GraphVertex_getPoint]
809
810 // [java_GraphVertex_getName]
811 // Get vertex name
812 String name = vertex.getName();
813 System.out.println("Vertex name: " + name);
814 // [java_GraphVertex_getName]
815
816 // [java_GraphVertex_getIsExternal]
817 // Get vertex external flag
818 boolean isExternal = vertex.getIsExternal();
819 System.out.println("Vertex is external: " + isExternal);
820 // [java_GraphVertex_getIsExternal]
821
822 // [java_GraphVertex_getIsElevation]
823 // Get vertex elevation flag
824 boolean isElevation = vertex.getIsElevation();
825 System.out.println("Vertex is elevation: " + isElevation);
826 // [java_GraphVertex_getIsElevation]
827 }
828
832 public void demonstrateGraphEdgeUsage(GraphEdge edge) {
833 if (edge == null) {
834 System.err.println("GraphEdge is null");
835 return;
836 }
837
838 // [java_GraphEdge_getWeight]
839 // Get edge weight
840 float weight = edge.getWeight();
841 System.out.println("Edge weight: " + weight);
842 // [java_GraphEdge_getWeight]
843
844 // [java_GraphEdge_getDst]
845 // Get destination vertex ID
846 int dst = edge.getDst();
847 System.out.println("Edge destination ID: " + dst);
848 // [java_GraphEdge_getDst]
849
850 // [java_GraphEdge_getSrc]
851 // Get source vertex ID
852 int src = edge.getSrc();
853 System.out.println("Edge source ID: " + src);
854 // [java_GraphEdge_getSrc]
855
856 // [java_GraphEdge_getWeightCoef]
857 // Get edge weight coefficient
858 int weightCoef = edge.getWeightCoef();
859 System.out.println("Edge weight coefficient: " + weightCoef);
860 // [java_GraphEdge_getWeightCoef]
861 }
862
866 public void demonstrateElevationGraphUsage(ElevationGraph elevationGraph) {
867 if (elevationGraph == null) {
868 System.err.println("ElevationGraph is null");
869 return;
870 }
871
872 // [java_ElevationGraph_getEdges]
873 // Get elevation graph edges
874 java.util.ArrayList<GraphEdge> edges = elevationGraph.getEdges();
875 System.out.println("Number of elevation graph edges: " + edges.size());
876
877 // Demonstrate each edge
878 for (int i = 0; i < edges.size(); i++) {
879 GraphEdge edge = edges.get(i);
880 System.out.println("Elevation graph edge " + (i + 1) + ":");
882 }
883 // [java_ElevationGraph_getEdges]
884 }
885
890 // [java_TransmitterStatus_values]
891 // Get all transmitter status values
892 TransmitterStatus[] statuses = TransmitterStatus.values();
893 System.out.println("Available transmitter statuses:");
894 for (TransmitterStatus status : statuses) {
895 System.out.println(" - " + status);
896 }
897 // [java_TransmitterStatus_values]
898 }
899
903 public void cleanup() {
904 if (locationManager != null && locationListener != null) {
905 // [java_LocationManager_removeLocationListener]
906 // Remove location listener
907 locationManager.removeLocationListener(locationListener);
908 // [java_LocationManager_removeLocationListener]
909 }
910 }
911
915 public void runExample() {
916 System.out.println("=== LocationManager Example ===");
917
920
921 // Wait a bit for location to load
922 try {
923 Thread.sleep(2000);
924 } catch (InterruptedException e) {
925 Thread.currentThread().interrupt();
926 }
927
928 cleanup();
929 System.out.println("=== Example completed ===");
930 }
931
935 public static void main(String[] args) {
937 example.runExample();
938 }
939}