iitc-project / ingress-intel-total-conversion

ingress.com/intel total conversion user script with some new features. Should allow easier extension of the intel map.
http://iitc.jonatkins.com/
ISC License
991 stars 553 forks source link

access to portal information database #1116

Open 0x70b1a5 opened 8 years ago

0x70b1a5 commented 8 years ago

IITC seems to be the API for accessing portals in an easy way. Is it possible to query the db of all known portals and get info like the image, name, latlong, etc?

MNoelJones commented 8 years ago

You can access the info for any portal that has been retrieved through the interface (see the portals list module, for example). There's also the cache option, which maintains the info for a number of previously viewed portals. This is definitely NOT the same as a database of all known portals! :)

0x70b1a5 commented 8 years ago

Cool, thank you. Follow up: is there a function to display ALL portals inside a map view, rather than just linked ones over a certain length?

hayeswise commented 7 years ago

Did you look at the "show list of portals" plug-in?

PrinterElf commented 7 years ago

The portals list plugin will only fire when you've zoomed in far enough to show portals rather than links.

billplaysonline commented 7 years ago

Is there a way to access the cashed portal information for the currently displayed portals. I am interested in being able to look at AP, MOD, Links, etc. But I don't want to query the server. Is this possible?

without-ordinary commented 7 years ago

@billplaysonline Look at the existing plugins that do use such info. You will still be limited to requiring the close zoom level for much of the info.

hayeswise commented 7 years ago

Without Ordinary provides good advice. For example, take a look at portals-list ( https://static.iitc.me/build/release/plugins/portals-list.user.js) as a starting point. You get the truncated level, team, health, num resonators, num links, fields, and AP. Mods are in the portal details which typically require you to click on the portal or, indirectly, via link as portals-list does it. You've already written about not wanting to query the server; thus, you seem to want a solution that keeps in the accepted spirit of the game where portal details require a human, or perhaps a trained frog 😀, to click on something.

If you continue pursuing your own solution further, you'll be getting into objects like window.portals, window.links, window.resonators and window.fields. These are accessible from your browser's console - thus, you can inspect them to understand their content.

I hope this is helpful!

On Fri, Dec 16, 2016 at 12:17 PM, Without Ordinary <notifications@github.com

wrote:

@billplaysonline https://github.com/billplaysonline Look at the existing plugins that do use such info. You will still be limited to requiring the close zoom level for much of the info.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/iitc-project/ingress-intel-total-conversion/issues/1116#issuecomment-267686374, or mute the thread https://github.com/notifications/unsubscribe-auth/AEGbQU_9xyJ-4vpDfZ6zyj4Y88WpEsHmks5rIvHfgaJpZM4JEBLi .

billplaysonline commented 7 years ago

While examining the wonderful information supplied I ran across what I would call a nuisance bug. The script works fine when at the proper portal layer. If not it just doesn't respond on the desktop and on mobile it brings up a blank popup. Anyway I added //fill the listPortals array with portals avaliable on the map (level filtered portals will not appear in the table) window.plugin.portalslist.getPortals = function() {

//filter : 0 = All, 1 = Neutral, 2 = Res, 3 = Enl, -x = all but x var retval=false; var displayBounds = map.getBounds();

//*** //BS Below added by billplaysonline AKA William Schlesinger schlesingeronline@gmail.com // This fixes the problem where if you click on get portals list and you are zoomed out too far it just dies. // Now it displays a message "nothing to show". var zoom = map.getZoom(); zoom = getDataZoomForMapZoom(zoom); var tileParams = getMapZoomTileParameters(zoom); if (tileParams.hasPortals === false) { return retval; } //BS end of change

window.plugin.portalslist.listPortals = [];

What is the proper way for me to have this done? I usually don't try and fix bugs, Just locate them and report them. but I found this in another script.

hayeswise commented 7 years ago

When the map is zoomed out all the way, 'map.getBounds()' is returning an invalid southwest longitude (e.g. -300.9375). We expect values -180 to +180.

McBen commented 7 years ago

@hayeswise http://stackoverflow.com/questions/18063278/leaflet-getbounds-returning-longitudes-greater-than-180 event.latlng.wrap().lng should help

hayeswise commented 7 years ago

Thanks! It did help.
My getPortalsInMapBounds function now does the following:

displayBounds = window.map.getBounds(); 
displayBounds.getSouthWest().wrap();
displayBounds.getNorthEast().wrap();

displayBounds.contains(portal.getLatLng()) now works as expected.

The mapZoomHasPortals() function in your fix #1169 is still useful to handle the case of the portal data not being there when the map is zoomed out to far (other readers: see billplaysonline post above with the code).

I made the following small change in the window.plugin.portalslist.fields.forEach(function (field, i) { loop that gathers the portal data for each row to make it more robust:

var value = field.value(portal);
if (typeof value === 'undefined') {
   value = "[unknown]"; // or set to blank
}

Thus, if the getPortalsInMapBounds check is not used, and you are sufficiently zoomed out, you'll get a portal list with all blank names and "[unknown]" for for various portal values.

nhamer commented 7 years ago

I don't believe there is anything actionable here? Can this issue be closed?

billplaysonline commented 7 years ago

Has the new portal-list been released? If so it is OK by me

nhamer commented 7 years ago

@billplaysonline I think your issue is actually bug #1161 ?

billplaysonline commented 7 years ago

@Nhamer I think you are correct.